strongloop / node-foreman

A Node.js Version of Foreman
http://strongloop.github.io/node-foreman/
Other
1.27k stars 119 forks source link

Export for systemd is not working correctly #122

Closed slavafomin closed 6 years ago

slavafomin commented 8 years ago

Hello!

I'm trying to export my Node.js application as systemd service on Ubuntu Server 15.10.

However, it looks like foreman is working incorrectly.

Exporting

$ sudo nf export --app web-testdrive --user web-testdrive -t systemd -o /lib/systemd/system/
[OKAY] Loaded ENV .env File as KEY=VALUE Format
[OKAY] Wrote  : /lib/systemd/system/web-testdrive-web-1.service
[OKAY] Wrote  : /lib/systemd/system/web-testdrive-web.target
[OKAY] Wrote  : /lib/systemd/system/web-testdrive.target

Contents of the generated files

$ cat /lib/systemd/system/web-testdrive-web-1.service
[Unit]
Description=web-testdrive-web-1
Requires=web-testdrive-web.target

[Service]
Type=simple
ExecStart=/usr/bin/env node app.js
WorkingDirectory=/var/www/testdrive/releases/1.11.15

User=web-testdrive
Group=web-testdrive

EnvironmentFile=-/var/www/testdrive/releases/1.11.15/.env
Environment=PORT=8001

StandardInput=null
StandardOutput=syslog
StandardError=syslog
Restart=always
$ cat /lib/systemd/system/web-testdrive-web.target
[Unit]
Requires=web-testdrive.target
Wants=web-testdrive-web-.service
$ cat /lib/systemd/system/web-testdrive.target
[Unit]
Wants=web-testdrive-.target

Starting the service

$ sudo systemctl start web-testdrive
Failed to start web-testdrive.service: Unit web-testdrive.service failed to load: No such file or directory.

I'm not familiar with how systemd is working, but it looks like links between the generated files are broken and the main testdrive.service file is missing.

Or am I doing something wrong maybe?

Any help will be highly appreciated. Thank you!

rgstephens commented 7 years ago

Try the command:

sudo systemctl enable web-testdrive
mkolodziej commented 7 years ago

For me it worked only after I added .target to the service name, like this:

sudo systemctl enable web-testdrive.target

stale[bot] commented 6 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.