Estou tentando executar automaticamente o seguinte comando na inicialização do sistema com o systemd.
/usr/bin/node /var/www/html/rest-api/dist/index.js
Verifiquei que o comando funciona executando-o manualmente, mas quando tento iniciá-lo com um arquivo rest.service
, estou recebendo erros.
rest.service:
[Unit]
Description=REST API
After=network.target
[Service]
ExecStart=/usr/bin/node /var/www/html/rest-api/dist/index.js
Restart=always
User=nobody
Group=nobody
Environment=PATH=/usr/bin:/usr/local/bin
Environment=NODE_ENV=production
WorkingDirectory=/var/www/rest-api/dist
[Install]
WantedBy=multi-user.target
journalctl -u rest-api
output:
Onde rest.service
usuário & amp; Grupo = ninguém:
Oct 06 02:10:28 ip-172-31-26-208 systemd[7172]: rest-api.service: Failed at step GROUP spawning /usr/bin/node: No such process
Oct 06 02:10:28 ip-172-31-26-208 systemd[1]: rest-api.service: Main process exited, code=exited, status=216/GROUP
Oct 06 02:10:28 ip-172-31-26-208 systemd[1]: rest-api.service: Unit entered failed state.
Oct 06 02:10:28 ip-172-31-26-208 systemd[1]: rest-api.service: Failed with result 'exit-code'.
Oct 06 02:10:29 ip-172-31-26-208 systemd[1]: rest-api.service: Service hold-off time over, scheduling restart.
Oct 06 02:10:29 ip-172-31-26-208 systemd[1]: Stopped REST API.
Onde rest.service
usuário & amp; Grupo = raiz:
Oct 06 02:20:11 ip-172-31-26-208 systemd[1]: Started REST API.
Oct 06 02:20:11 ip-172-31-26-208 systemd[1]: rest-api.service: Main process exited, code=exited, status=200/CHDIR
Oct 06 02:20:11 ip-172-31-26-208 systemd[1]: rest-api.service: Unit entered failed state.
Oct 06 02:20:11 ip-172-31-26-208 systemd[1]: rest-api.service: Failed with result 'exit-code'.
Oct 06 02:20:12 ip-172-31-26-208 systemd[1]: rest-api.service: Service hold-off > time over, scheduling restart.
Oct 06 02:20:12 ip-172-31-26-208 systemd[1]: Stopped REST API.
Alguma ideia de como corrigir?