We have a nodejs based server that is configured to be launched by systemd and on our dev server new versions are deployed via continuous integration. The issue we have is that a non-root user can not restart the application using the systemctl command, so we are curious how we should approach the problem?
The command we tried:
sudo systemctl start my-nodejs-server
And the contents of the systemd script:
[Unit]
Description=NodeJS Based Server
[Install]
WantedBy=multi-user.target
[Service]
User=myserver-user
Group=myserver-userh
Environment=ENV=production NODE_ENV=production
WorkingDirectory=/home/myserver-user/my-nodejs-server/
#ExecStart=/home/myserver-user/my-nodejs-server/scripts/appctl.sh restart
ExecStart=/usr/bin/node lib
Restart=on-failure
I have also tried the following command, as suggested:
systemctl --user start my-nodejs-server
but I get the following:
Failed to connect to bus: No such file or directory
Any ideas?
We are running on Ubuntu 16.
systemctl status...
is not going to start anything. – jasonwryan Feb 08 '18 at 23:19systemctl --user start myservice
... – jasonwryan Feb 08 '18 at 23:42export XDG_RUNTIME_DIR="/run/user/$UID"
if doingsudo su - myuser
or a proper login (ssh myuser@localhost
) to the given account resolved that. Do you want to put all this as an answer, so you get credit? – Andre M Feb 09 '18 at 04:29