我希望节点服务器在后台运行。我已经读过该线程:How do I run a Node.js application as its own process?
我收到错误消息:
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文件:
[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
我尝试将“ nobody”作为组,我尝试省略用户和组,但出现此错误:
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
如果我转到some-directory
并输入node index.js
,一切正常(包括NODE_ENV =开发设置)。
答案 0 :(得分:0)
您似乎试图将服务作为系统实例运行,但是服务本身定义为用户实例(通过使用User =)
尝试将.service文件复制到/ etc / systemd / user 使用systemctl --user选项运行和监视系统。
要允许该服务在用户的最后一个会话关闭后仍保留,请在此处查看loginctl: https://wiki.archlinux.org/index.php/Systemd/User