Autostart Node apps on Intel Edison

Published 2015 05 05

Here I will show the simplest way to autostart Node.js apps on Intel Edison board

It is very easy to install any javascript app trough npm command on Intel Edison, because Node.js is installed by default. But sooner or later you'd have to start programs automatically. Here I will show the simplest way to autostart Node.js apps on Intel Edison board.

  • Check folder /etc/systemd/system:

    ls -l /etc/systemd/system/*.service
    

    there are few System Service Manager configuration files with .services extension

  • For example I will use openautomation service, please rename your file accordingly. Create a service config file /etc/systemd/system/openautomation.service with structure like this:

      [Unit]
      Description=Open Automation Service
      After=network.service
    
      [Service]
      ExecStart=/bin/sh -c "/usr/bin/node /home/oa/node_modules/openautomation/app.js"
      WorkingDirectory=/home/oa/node_modules/openautomation/
      Restart=always
      RestartSec=5s
    
      [Install]
      WantedBy=multi-user.target
    
  • Set executable rights to everyone:

    chmod 777 /etc/systemd/system/openautomation.service
    
  • Reload systemctl daemon:

    systemctl daemon-reload
    
  • Start your service:

    systemctl start openautomation.service
    
  • Check service status:

    systemctl status
    systemctl status openautomation.service
    

This is most important command, you will get console messages from node.js app.

  • Enable service autostart feature:

    systemctl enable openautomation.service
    
  • Restart service:

    systemctl restart openautomation.service
    

For more info about systemd daemon please read here .

Back to Projects