I'm working on a Rest Service working with NodeJS(iojs) on an old Raspberry Pi 1 running on Arch Linux. Everything works fine but its not starting on Reboot.
What I tried: Crontab without user:
crontab -e
@reboot /usr/local/iojs/bin/forever start /x/y/server.js
and with user:
crontab -u x -e
@reboot /usr/bin/sudo -u x -H /usr/local/iojs/bin/forever start /x/y/server.js
Both versions work manually executed. I also tried to do it with systemctrl:
/etc/systemd/system/rest_api.service
[Unit]
Description=Rest Api
[Service]
ExecStart=/x/y/rest_api/start_service.sh
Restart=always
[Install]
WantedBy=multi-user.target
This should execute start_service.sh:
#!/bin/sh
forever start /usr/local/rest_api/server.js
exit
Starting it throws an error
systemctl start rest_api
Error getting authority: Error initializing authority: Error calling StartServiceByName for org.freedesktop.PolicyKit1: Timeout was reached (g-io-error-quark, 24)
Failed to start rest_api.service: Connection timed out
I'm a beginner in some of those topics, therefore I'm struggling to find the mistake. Actually I think this should be simple.
Thank you, Matthias
If some people are still interested, this works perfectly:
1) npm install forever -g && npm install forever-service -g
2) rename your js script to app.js, go to its location with cd and type:
forever-service install myService
3) add the following line in /etc/rc.local :
sudo service myService start
I hope it will help!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With