2023-04-10 15:36:59 +00:00
|
|
|
# Copyright (c) HashiCorp, Inc.
|
|
|
|
# SPDX-License-Identifier: MPL-2.0
|
|
|
|
|
2023-06-26 14:51:18 +00:00
|
|
|
job "java_host" {
|
|
|
|
type = "batch"
|
|
|
|
|
|
|
|
constraint {
|
|
|
|
attribute = "${attr.kernel.name}"
|
|
|
|
value = "linux"
|
|
|
|
}
|
|
|
|
|
|
|
|
group "group" {
|
|
|
|
|
|
|
|
|
|
|
|
reschedule {
|
|
|
|
attempts = 0
|
|
|
|
unlimited = false
|
|
|
|
}
|
|
|
|
|
|
|
|
restart {
|
|
|
|
attempts = 0
|
|
|
|
mode = "fail"
|
|
|
|
}
|
2021-02-08 16:36:11 +00:00
|
|
|
|
|
|
|
|
|
|
|
task "build" {
|
|
|
|
lifecycle {
|
|
|
|
hook = "prestart"
|
|
|
|
sidecar = false
|
|
|
|
}
|
|
|
|
|
|
|
|
driver = "exec"
|
|
|
|
config {
|
|
|
|
command = "javac"
|
|
|
|
args = ["-d", "${NOMAD_ALLOC_DIR}", "local/Pid.java"]
|
|
|
|
}
|
|
|
|
|
|
|
|
template {
|
|
|
|
destination = "local/Pid.java"
|
|
|
|
data = <<EOH
|
|
|
|
public class Pid {
|
|
|
|
public static void main(String... s) throws Exception {
|
|
|
|
System.out.println("my pid is " + ProcessHandle.current().pid());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
EOH
|
|
|
|
}
|
2023-06-26 14:51:18 +00:00
|
|
|
|
|
|
|
resources {
|
|
|
|
cpu = 50
|
|
|
|
memory = 64
|
|
|
|
}
|
2021-02-08 16:36:11 +00:00
|
|
|
}
|
|
|
|
|
2023-06-26 14:51:18 +00:00
|
|
|
task "java" {
|
2021-02-08 16:36:11 +00:00
|
|
|
driver = "java"
|
|
|
|
config {
|
|
|
|
class_path = "${NOMAD_ALLOC_DIR}"
|
|
|
|
class = "Pid"
|
|
|
|
pid_mode = "host"
|
|
|
|
ipc_mode = "host"
|
|
|
|
}
|
2023-06-26 14:51:18 +00:00
|
|
|
|
|
|
|
resources {
|
|
|
|
cpu = 50
|
|
|
|
memory = 64
|
|
|
|
}
|
2021-02-08 16:36:11 +00:00
|
|
|
}
|
|
|
|
}
|
2023-06-26 14:51:18 +00:00
|
|
|
}
|