fix: systemd unit starts per-instance NGINX before Wallarm services
This commit is contained in:
parent
d8390eab2a
commit
b86d9d3604
1 changed files with 11 additions and 12 deletions
|
|
@ -223,38 +223,37 @@ func Status(nodeName string) (string, error) {
|
|||
return sb.String(), nil
|
||||
}
|
||||
|
||||
// GenerateSystemdTemplate creates the wallarm-node@.service template unit if it doesn't exist.
|
||||
// GenerateSystemdTemplate creates the wallarm-node@.service template unit.
|
||||
func GenerateSystemdTemplate() error {
|
||||
if _, err := os.Stat(SystemdTemplate); err == nil {
|
||||
return nil // already exists
|
||||
return nil
|
||||
}
|
||||
|
||||
content := fmt.Sprintf(`[Unit]
|
||||
Description=Wallarm Native Node - %%I
|
||||
Description=Wallarm Node - %%i
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
Type=forking
|
||||
WorkingDirectory=%s/%%i
|
||||
EnvironmentFile=%s/%%i/env
|
||||
ExecStart=%s/%%i/wallarm-native-node-aio.sh start
|
||||
ExecStop=%s/%%i/wallarm-native-node-aio.sh stop
|
||||
ExecStartPre=%s/%%i/nginx/sbin/nginx -c %s/%%i/nginx/conf/nginx.conf -t
|
||||
ExecStart=%s/%%i/nginx/sbin/nginx -c %s/%%i/nginx/conf/nginx.conf
|
||||
ExecStartPost=/bin/bash %s/%%i/supervisord.sh start
|
||||
ExecStop=/bin/bash %s/%%i/supervisord.sh stop
|
||||
ExecStopPost=/bin/bash -c '%s/%%i/nginx/sbin/nginx -s quit 2>/dev/null || true'
|
||||
Restart=on-failure
|
||||
RestartSec=5
|
||||
User=root
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
`, NodesDir, NodesDir, NodesDir, NodesDir)
|
||||
`, NodesDir, NodesDir, NodesDir, NodesDir, NodesDir, NodesDir, NodesDir, NodesDir)
|
||||
|
||||
if err := os.WriteFile(SystemdTemplate, []byte(content), 0644); err != nil {
|
||||
return fmt.Errorf("write systemd template: %w", err)
|
||||
}
|
||||
|
||||
cmd := exec.Command("systemctl", "daemon-reload")
|
||||
if out, err := cmd.CombinedOutput(); err != nil {
|
||||
return fmt.Errorf("daemon-reload: %w\n%s", err, string(out))
|
||||
}
|
||||
exec.Command("systemctl", "daemon-reload").Run()
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue