Nodejs에 대한 사용자 정의 시스템 서비스를 시작할 수 없습니다: 노드를 찾을 수 없습니다

Nodejs에 대한 사용자 정의 시스템 서비스를 시작할 수 없습니다: 노드를 찾을 수 없습니다

설치했습니다로켓대화방내 Debian Jessie에서는 잘 작동하고 부팅 시 자동으로 서비스로 시작되기를 원합니다.

Rocket.chat을 수동으로 시작하려면 다음이 필요합니다.

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

이 내 꺼야/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

서비스가 시작되지 않았습니다:

# 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.

이것은 /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존재하다:

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

/usr/local/bin/node찾을 수 없는 문제를 해결하는 방법은 무엇입니까?

답변1

ExecStart~해야 한다

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

이것은 내 파일(/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

서비스를 시작합니다:sudo systemctl start rocketchat

신병:sudo systemctl enable rocketchat

관련 정보