Start Node application on Linux boot (Raspberry)

Asked

Viewed 69 times

0

Good afternoon to all,

I have a JS application that needs to be started on Linux boot, how could I start this application? I tried with systemd, but it didn’t work. Could you give me some link or tip? Any error in the file below?

service manager.

[Unit]
Description=Gerente
After=syslog.target

[Service]
ExecStart=/home/eu/projetos/node/socket5/npm start
RuntimeDirectory=socket5
Restart=always
KillSignal=SIGQUIT
Type=notify
StandardError=syslog
NotifyAccess=all

[Install]
WantedBy=multi-user.target
[Unit]
Description=Gerente
After=syslog.target

Execution:

root@raspberry:/etc/systemd/system# systemctl start gerente.service
Job for gerente.service failed because the control process exited with error code.
See "systemctl status gerente.service" and "journalctl -xe" for details.
root@raspberry:/etc/systemd/system# systemctl status gerente.service
● gerente.service - Gerente
   Loaded: loaded (/etc/systemd/system/gerente.service; disabled; vendor preset: enabled)
   Active: failed (Result: exit-code) since Thu 2019-02-07 16:48:20 -02; 27s ago
  Process: 1397 ExecStart=/home/harley/projetos/node/socket5/npm start (code=exited, status=203/EXEC)
 Main PID: 1397 (code=exited, status=203/EXEC)

fev 07 16:48:19 raspberry systemd[1]: gerente.service: Unit entered failed state.
fev 07 16:48:19 raspberry systemd[1]: gerente.service: Failed with result 'exit-code'.
fev 07 16:48:20 raspberry systemd[1]: gerente.service: Service hold-off time over, scheduling restart.
fev 07 16:48:20 raspberry systemd[1]: Stopped Gerente.
fev 07 16:48:20 raspberry systemd[1]: gerente.service: Start request repeated too quickly.
fev 07 16:48:20 raspberry systemd[1]: Failed to start Gerente.
fev 07 16:48:20 raspberry systemd[1]: gerente.service: Unit entered failed state.
fev 07 16:48:20 raspberry systemd[1]: gerente.service: Failed with result 'exit-code'.
  • Use the PM2

  • I will analyze PM2, thanks @Valdeirpsr.

  • I found the solution good, but when restarting Raspberry, the application does not start automatically. You can configure PM2 to start processes on boot.

  • I checked that there is how, I am analyzing...

  • @Valdeirpsr got it. Excellent solution, meets perfectly. Can you reply so I mark your answer as solution? Thank you very much.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.