1

I installed Rocket.chat on my Debian Jessie, it works well and I want to start it automatically at boot as a service.

To start Rocket.chat manually I need to

$ cd /home/hung/Rocket.chat
$ node main.js

This is my /etc/systemd/system/rocket-chat.service

[Service]
ExecStart=/usr/local/bin/node main.js
Restart=always
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=rocket-chat
User=hung
Group=hung
WorkingDirectory=/home/hung/Rocket.chat

[Install]
WantedBy=multi-user.target

The service doesn't start:

# systemctl start rocket-chat
# systemctl status rocket-chat
● rocket-chat.service
   Loaded: loaded (/etc/systemd/system/rocket-chat.service; disabled)
   Active: failed (Result: start-limit) since Fri 2018-03-02 22:30:16 +07; 4s ago
  Process: 1169 ExecStart=/usr/local/bin/node main.js (code=exited, status=200/CHDIR)
 Main PID: 1169 (code=exited, status=200/CHDIR)

Mar 02 22:30:16 debian systemd[1]: rocket-chat.service: main process exited, code=exited, status=200/CHDIR
Mar 02 22:30:16 debian systemd[1]: Unit rocket-chat.service entered failed state.
Mar 02 22:30:16 debian systemd[1]: rocket-chat.service holdoff time over, scheduling restart.
Mar 02 22:30:16 debian systemd[1]: Stopping rocket-chat.service...
Mar 02 22:30:16 debian systemd[1]: Starting rocket-chat.service...
Mar 02 22:30:16 debian systemd[1]: rocket-chat.service start request repeated too quickly, refusing to start.
Mar 02 22:30:16 debian systemd[1]: Failed to start rocket-chat.service.
Mar 02 22:30:16 debian systemd[1]: Unit rocket-chat.service entered failed state.

Here is what in /var/log/syslog:

# tail /var/log/syslog 
Mar  2 22:17:21 debian systemd[1]: Started rocket-chat.service.
Mar  2 22:17:21 debian systemd[1068]: Failed at step CHDIR spawning /usr/local/bin/node: No such file or directory
Mar  2 22:17:22 debian systemd[1]: rocket-chat.service: main process exited, code=exited, status=200/CHDIR
Mar  2 22:17:22 debian systemd[1]: Unit rocket-chat.service entered failed state.
Mar  2 22:17:22 debian systemd[1]: rocket-chat.service holdoff time over, scheduling restart.
Mar  2 22:17:22 debian systemd[1]: Stopping rocket-chat.service...
Mar  2 22:17:22 debian systemd[1]: Starting rocket-chat.service...
Mar  2 22:17:22 debian systemd[1]: rocket-chat.service start request repeated too quickly, refusing to start.
Mar  2 22:17:22 debian systemd[1]: Failed to start rocket-chat.service.
Mar  2 22:17:22 debian systemd[1]: Unit rocket-chat.service entered failed state.

/usr/local/bin/node exists:

$ /usr/local/bin/node --version
v8.9.3

How do I solve the problem that /usr/local/bin/node is not found?

2
  • The error message is a bit misleading. I believe it is saying it can't find /home/hung/Rocket.chat, not node. Does the hung user have access to that directory?
    – jordanm
    Commented Mar 2, 2018 at 16:18
  • @jordanm Yes the user owns the folder and its files drwxr-xr-x 4 hung hung 4096 Feb 28 08:11 Rocket.Chat
    – Hung Tran
    Commented Mar 3, 2018 at 1:52

1 Answer 1

1

ExecStart should be

ExecStart=/usr/local/bin/node /home/hung/Rocket.chat/main.js

This is my final version of the file (/etc/systemd/system/rocketchat.service):

[Unit]
Description=RocketChat Server
After=network.target remote-fs.target nss-lookup.target mongod.target apache2.target

[Service]
ExecStart=/home/hung/.nvm/versions/node/v8.9.3/bin/node /var/www/chat/Rocket.Chat/main.js
Restart=always
RestartSec=10
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=rocketchat
Environment=NODE_ENV=production
Environment=PORT=3001
Environment=ROOT_URL=https://domain.com/
Environment=MONGO_URL=mongodb://localhost:27017/rocketchat
Environment=MAIL_URL='smtp://user@domain:password@domain:587/'

[Install]
WantedBy=multi-user.target

Start the service: sudo systemctl start rocketchat

Start on boot: sudo systemctl enable rocketchat

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .