5 Replies Latest reply on Feb 27, 2015 3:28 PM by mhahn

    systemd service starting

    joshuajnoble

      I'm trying to create a service that will launch on startup and create a node server

       

       

      In my /etc/systemd/system/ I create the following file: denny.service

       

       

      [Unit]
      Description=Denny node server start
      [Service]
      ExecStart=/bin/sh /home/root/denny.sh
      User=root
      Group=root
      Environment=NODE_ENV=production
      Restart=always
      [Install]
      WantedBy=multi-user.target
      
      

       

      I refresh the systemctl daemon and then reboot and then on boot I see:

       

       

      root@denny:~# systemctl status denny
      ● denny.service - Denny node server start
         Loaded: loaded (/etc/systemd/system/denny.service; enabled)
         Active: activating (auto-restart) since Fri 2015-02-13 20:59:01 UTC; 99ms ago
      Main PID: 1235 (code=exited, status=0/SUCCESS)
      
      

       

      Here is the .sh file I'm trying to start:

       

       

      #!/bin/sh
      
      systemctl enable hostapd
      /usr/bin/node /home/root/server.js &
      

       

      When I start it after logging in it runs in the background without a problem.

       

      How can I get this service to start my node server and keep it running?