Unable to start custom systemd service for Nodejs: Node not found
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?
linux debian systemd node.js
bumped to the homepage by Community♦ 1 hour ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
add a comment |
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?
linux debian systemd node.js
bumped to the homepage by Community♦ 1 hour ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
The error message is a bit misleading. I believe it is saying it can't find/home/hung/Rocket.chat
, not node. Does thehung
user have access to that directory?
– jordanm
Mar 2 '18 at 16:18
@jordanm Yes the user owns the folder and its filesdrwxr-xr-x 4 hung hung 4096 Feb 28 08:11 Rocket.Chat
– Hung Tran
Mar 3 '18 at 1:52
add a comment |
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?
linux debian systemd node.js
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?
linux debian systemd node.js
linux debian systemd node.js
asked Mar 2 '18 at 15:37
Hung TranHung Tran
1937
1937
bumped to the homepage by Community♦ 1 hour ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
bumped to the homepage by Community♦ 1 hour ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
The error message is a bit misleading. I believe it is saying it can't find/home/hung/Rocket.chat
, not node. Does thehung
user have access to that directory?
– jordanm
Mar 2 '18 at 16:18
@jordanm Yes the user owns the folder and its filesdrwxr-xr-x 4 hung hung 4096 Feb 28 08:11 Rocket.Chat
– Hung Tran
Mar 3 '18 at 1:52
add a comment |
The error message is a bit misleading. I believe it is saying it can't find/home/hung/Rocket.chat
, not node. Does thehung
user have access to that directory?
– jordanm
Mar 2 '18 at 16:18
@jordanm Yes the user owns the folder and its filesdrwxr-xr-x 4 hung hung 4096 Feb 28 08:11 Rocket.Chat
– Hung Tran
Mar 3 '18 at 1:52
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
Mar 2 '18 at 16:18
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
Mar 2 '18 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
Mar 3 '18 at 1:52
@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
Mar 3 '18 at 1:52
add a comment |
1 Answer
1
active
oldest
votes
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
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "106"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f427712%2funable-to-start-custom-systemd-service-for-nodejs-node-not-found%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
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
add a comment |
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
add a comment |
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
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
answered Mar 27 '18 at 0:06
Hung TranHung Tran
1937
1937
add a comment |
add a comment |
Thanks for contributing an answer to Unix & Linux Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f427712%2funable-to-start-custom-systemd-service-for-nodejs-node-not-found%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
The error message is a bit misleading. I believe it is saying it can't find
/home/hung/Rocket.chat
, not node. Does thehung
user have access to that directory?– jordanm
Mar 2 '18 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
Mar 3 '18 at 1:52