Skip to content

Commit

Permalink
chore(node-red): add rolling updates and install pre-task to node-red…
Browse files Browse the repository at this point in the history
… job

Signed-off-by: Bruce Becker <[email protected]>
  • Loading branch information
brucellino committed Jan 6, 2022
1 parent cf65f1a commit 4656d13
Showing 1 changed file with 60 additions and 5 deletions.
65 changes: 60 additions & 5 deletions node-red.nomad
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
job "nodered" {
datacenters = ["dc1"]

update {
max_parallel = 2
health_check = "checks"
canary = 1
auto_promote = true
auto_revert = true
}
group "automation" {
count = 1

Expand Down Expand Up @@ -28,16 +34,65 @@ job "nodered" {
}
}

task "nodered_server" {
task "install" {
driver = "raw_exec"
lifecycle {
hook = "prestart"
}
env {
XDG_CONFIG_HOME = "${NOMAD_ALLOC_DIR}"
}
template {
data = <<EOT
#!/bin/bash
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash
echo ${XDG_CONFIG_HOME}
pwd
ls -lht
source ${XDG_CONFIG_HOME}/nvm/nvm.sh
nvm install --lts 16
nvm use 16
npm install -g --unsafe-perm node-red
EOT
destination = "install.sh"
perms = "0755"
}
config {
command = "/bin/bash"
args = ["install.sh"]
}

resources {
cores = 2
memory = 800
cpu = 1000
memory = 256
memory_max = 512
}
} // install task

task "nodered" {
driver = "raw_exec"
env {
XDG_CONFIG_HOME = "${NOMAD_ALLOC_DIR}"
}
template {
destination = "run.sh"
data = <<EOT
#!/bin/bash
source ${XDG_CONFIG_HOME}/nvm/nvm.sh
nvm use 16
node-red-pi --max-old-space-size=256
EOT
perms = "0755"
}
config {
command = "node-red"
command = "/bin/bash"
args = ["run.sh"]
}

resources {
cores = 2
memory = 1024
memory_max = 2048
}
}
}
Expand Down

0 comments on commit 4656d13

Please sign in to comment.