-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathnode-red.nomad
140 lines (132 loc) · 2.65 KB
/
node-red.nomad
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
job "nodered" {
datacenters = ["dc1"]
meta {
auto-backup = true
backup-schedule = "@daily"
backup-target-db = "postgres"
}
update {
max_parallel = 1
health_check = "checks"
canary = 1
auto_promote = true
auto_revert = true
}
group "automation" {
count = 1
constraint {
attribute = "${attr.unique.consul.name}"
operator = "=="
value = "sense"
}
network {
port "ui" {}
}
service {
tags = ["automation", "nodered", "urlprefix-/nodered"]
port = "ui"
check {
type = "http"
port = "ui"
path = "/nodered/"
interval = "10s"
timeout = "5s"
}
check_restart {
grace = "600s"
limit = 2
}
}
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 {
cpu = 250
memory = 256
// memory_max = 512
}
} // install task
task "nodered" {
driver = "exec"
env {
XDG_CONFIG_HOME = "${NOMAD_ALLOC_DIR}"
PORT = "${NOMAD_PORT_ui}"
}
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 --settings settings.js
EOT
perms = "0755"
}
template {
destination = "settings.js"
data = <<EOT
module.exports = {
uiPort: process.env.PORT || 1880,
httpAdminRoot: "/nodered",
httpStatic: '/nodered/node-red-static',
logging: {
console: {
level: "warn",
metrics: false,
audit: false,
}
},
editorTheme: {
page: {
title: "${NOMAD_TASK_NAME} (${NOMAD_JOB_ID})"
},
theme: "solarized-dark",
codeEditor: {
lib: "monaco",
options: {
theme: "github",
fontSize: 20,
fontFamily: "Cascadia Code, Fira Code, Consolas, 'Courier New', monospace",
fontLigatures: true,
}
}
}
}
EOT
}
config {
command = "/bin/bash"
args = ["run.sh"]
}
resources {
cores = 1
memory = 1024
// memory_max = 2048
}
}
}
}