Unable to start custom systemd service for Nodejs: Node not found












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?










share|improve this question














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
















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?










share|improve this question














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














1












1








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?










share|improve this question














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






share|improve this question













share|improve this question











share|improve this question




share|improve this question










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



















  • 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

















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










1 Answer
1






active

oldest

votes


















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






share|improve this answer























    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
    });


    }
    });














    draft saved

    draft discarded


















    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









    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






    share|improve this answer




























      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






      share|improve this answer


























        1












        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






        share|improve this answer













        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







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Mar 27 '18 at 0:06









        Hung TranHung Tran

        1937




        1937






























            draft saved

            draft discarded




















































            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.




            draft saved


            draft discarded














            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





















































            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







            Popular posts from this blog

            CARDNET

            Boot-repair Failure: Unable to locate package grub-common:i386

            濃尾地震