3 Replies Latest reply on Aug 3, 2015 7:08 AM by ArtyomKhvediouk

    Running service which starts up node server.

    ArtyomKhvediouk

      So I have written an node js server which runs just fine , located at /home/root/main.js

       

      Created runServer.sh script :

      "#!/bin/sh

      nohup node /home/root/main.js &"

       

      when I ran the script . the server is up and running , great till now .

       

      I went on and created a service, that will run the server everytime the board boots up . located at /etc/systemd/system/nodeTestServer.service :

      "

      [Unit]

      Description= NodeJS_Server

       

      [Service]

      Type=idle

      RemainAfterExit=true

      ExecStart=/home/root/runServer

      Environment="HOME=/home/root"

      WorkingDirectory=/home/root/

       

       

      [Install]

      WantedBy=multi-user.target

      "

       

      when I run systemctl start nodeTestServer.service , and then check the status -I get :

      ● nodeTestScript.service - Node JS REST Server

         Loaded: loaded (/etc/systemd/system/nodeTestScript.service; enabled)

         Active: active (exited) since Sun 2015-06-07 13:49:07 UTC; 1min 37s ago

        Process: 482 ExecStart=/home/root/runServer (code=exited, status=0/SUCCESS)

      Main PID: 482 (code=exited, status=0/SUCCESS)

         CGroup: /system.slice/nodeTestScript.service

       

       

      Jun 07 13:49:08 testSSH runServer[482]: at Function.Module._resolveFilename (module.js:338:15)

      Jun 07 13:49:08 testSSH runServer[482]: at Function.Module._load (module.js:280:25)

      Jun 07 13:49:08 testSSH runServer[482]: at Module.require (module.js:364:17)

      Jun 07 13:49:08 testSSH runServer[482]: at require (module.js:380:17)

      Jun 07 13:49:08 testSSH runServer[482]: at Object.<anonymous> (/home/root/main.js:10:12)

      Jun 07 13:49:08 testSSH runServer[482]: at Module._compile (module.js:456:26)

      Jun 07 13:49:08 testSSH runServer[482]: at Object.Module._extensions..js (module.js:474:10)

      Jun 07 13:49:08 testSSH runServer[482]: at Module.load (module.js:356:32)

      Jun 07 13:49:08 testSSH runServer[482]: at Function.Module._load (module.js:312:12)

      Jun 07 13:49:08 testSSH runServer[482]: at Function.Module.runMain (module.js:497:10)

       

      any Idea ?

       

      Thanks in advance !