1

I created crsupp.service and cloudradio.sh files and trying to start my discord bot made in NodeJS.

When i typed systemctl start crsupp and then systemctl status crsupp I got this:

● crsupp.service - CRBeta
   Loaded: loaded (/etc/systemd/system/crsupp.service; disabled; vendor preset: enabled)
   Active: failed (Result: start-limit-hit) since Wed 2019-05-01 13:48:08 UTC; 293ms ago
  Process: 27479 ExecStart=/home/justwolf/crsupp/cloudradio.sh (code=exited, status=203/EXEC)
 Main PID: 27479 (code=exited, status=203/EXEC)

May 01 13:48:08 Nara systemd[1]: crsupp.service: Service hold-off time over, scheduling restart.
May 01 13:48:08 Nara systemd[1]: Stopped CRBeta.
May 01 13:48:08 Nara systemd[1]: crsupp.service: Start request repeated too quickly.
May 01 13:48:08 Nara systemd[1]: Failed to start CRBeta.
May 01 13:48:08 Nara systemd[1]: crsupp.service: Unit entered failed state.
May 01 13:48:08 Nara systemd[1]: crsupp.service: Failed with result 'start-limit-hit'.

crsupp.service:

[Unit]
Description=CRSupp

[Service]
Environment=NODE_ENV=production
User=root
WorkingDirectory=/home/justwolf/crsupp
ExecStart=cloudradio.sh
Restart=always

[Install]
WantedBy=default.target

cloudradio.sh:

#!/usr/bin/env node
node index.js
JustWolf
  • 13
  • 1
  • 5
  • This error is probably clouding the real error (this is a systemd issue that can be resolved by adjusting the restart interval) - what happens if you run `node index.js` manually from the terminal? – James May 01 '19 at 14:02
  • It normally started my discord bot. – JustWolf May 01 '19 at 14:03

3 Answers3

1

I experienced this problem and found my ExecStart line referred to a node install in "/user/bin/nodejs" when it WAS installed in "/user/bin/node" (without the js)

Bad code:

ExecStart=/usr/bin/nodejs /home/sammy/NodeWebhooks/webhook.js

Solved with:

ExecStart=/usr/bin/node /home/sammy/NodeWebhooks/webhook.js
Luke Graham
  • 109
  • 1
  • 6
0

The restart issue is a systemd issue that can be fixed by increasing the restart interval, this has already been addressed in another question.

With regards to your code though, the issue would seem to me that you have written a Node bash script but not actually put valid Node code in there. If all you want to do with the service is start a Node script then you can do this directly from the service

ExecStart=/path/to/node ./index.js
James
  • 80,725
  • 18
  • 167
  • 237
  • Still same problem – JustWolf May 01 '19 at 18:37
  • @JustWolf just looking back at your answer, you aren't doing everything I said :) you weren't pointing `ExecPath` to the path of where the Node application resides, you were just pointing it back to your working directory. – James May 14 '19 at 11:43
0

In my case the error message was somewhat misleading.

The reason for the failure was found in the definition file. It resulted from a copy between machines. The line

User=my_user 

in my service configuration file /etc/systemd/system/infinite_script.service was the culprit.

The new machine did not know of this user. Changing to User=root solved this problem.

kklepper
  • 763
  • 8
  • 13