0

I want node server to run in background. I've read that thread: How do I run a Node.js application as its own process?

I get errors:

systemd[10948]: myapp_test.service: Failed to determine group credentials: No such process
systemd[10948]: myapp_test.service: Failed at step GROUP spawning /some-directory/index.js: No such process

myapp_test.service file:

[Unit]
Description=Something

[Service]
ExecStart=/some-directory/index.js
Restart=always
User=nobody
# Note Debian/Ubuntu uses 'nogroup', RHEL/Fedora uses 'nobody'
Group=nogroup
Environment=PATH=/usr/bin:/usr/local/bin
Environment=NODE_ENV=development
WorkingDirectory=/some-directory/

[Install]
WantedBy=multi-user.target

I've tried "nobody" as group, I've tried to ommit both user and group but I get this error:

systemd[11543]: myapp_test.service: Failed to execute command: Permission denied
systemd[11543]: myapp_test.service: Failed at step EXEC spawning /some-directory/index.js: Permission denied

If I go to some-directory and type node index.js everything works fine (including NODE_ENV=development setting).

ElChupacabra
  • 1,045
  • 10
  • 18

1 Answers1

0

You seem to be attempting to run a service as a system instance but the service itself defined in as a user-instance(by using User=)

Try copying the .service file to /etc/systemd/user Run and monitor the system with systemctl --user options.

To allow the service to remain after the last session of the user is closed look into loginctl here: https://wiki.archlinux.org/index.php/Systemd/User

Sachin Myneni
  • 273
  • 3
  • 14