Logo
  • Home
  • Blog
    • Network
    • Android
    • Raspberry Pi
    • Server
    • Hacking
    • Arduino
    • C/C++
    • PHP
    • All
  • About Us
  • Contact
made withby us
30/04/2016
Omar AFLAK
Network, Raspberry Pi, Server
2

Node.js script at startup

Previous Next

I've been searching a while how to run a Node.js program at the boot of my Raspberry Pi and only one technique worked for me. Moreover I found it very simple!

forever and forever-service

Basically, what you have to do is make your program a service and then run the service automatically at the startup.

Install forever as global :

1
npm install forever -g

Then install forever-service : the key program here!

1
npm install forever-service -g

This is the github link: https://github.com/zapty/forever-service

Then, you HAVE TO rename your program to app.js. Lets say we want our service to be called myService, we run this command in the same directory than app.js :

1
forever-service install myService

If everything went right, you are now able to start|stop|restart your service like this:

1
2
3
service myService start
service myService stop
service myService restart

Run at startup

To run the service at the startup, open the file /etc/rc.local :

1
sudo nano /etc/rc.local

And add to the end (but before exit 0) the following line:

1
sudo service myService start

sudo is important here!

 

This is it you can reboot your server, and the service should run!

NetworkRaspberry PiServer
Share this

The Author Omar AFLAK

More Posts Like This One

HC-SR04 on Raspberry Pi in C++

HC-SR04 on Raspberry Pi in C++

15/04/2016
SSL Apache – Let’s Encrypt

SSL Apache – Let’s Encrypt

03/01/2016
Reverse Shell

Reverse Shell

17/04/2016
2 Comments General

Recent Posts

  • Flask API for Keras
  • Neural Network from scratch in Python
  • Neural Network from scratch: Part 2 – Practice
  • Neural Network from scratch: Part 1 – Theory
  • Connect Arduino to Android through USB

Tags

adb address android apache application arduino backdoor c client code communication connection debug example gradient descent hack hook i2c library machine learning matrix network neural network node.js oauth oauth2 php pi program python sample serial server serveur socket ssh symfony symfony2 tcp tcp/ip tuto tutorial USB win32api Windows

2 Comments

  • Smarthome Automatisierung mit Alexa, Homematic und Raspberry Pi
    14 February 2017 at 23 h 53 min

    […] Open Link […]

    Reply
  • Cıvata
    14 June 2016 at 18 h 18 min

    […] https://causeyourestuck.io/2016/04/30/run-node-js-script-startup/ […]

    Reply

Leave A Comment Cancel reply