How to start nodejs application automatically on openwrt - Arduino Yun -

arduino yún pinout
wiki arduino yún
arduino yún dimensions
arduino yun tutorial
arduino yun bluetooth
arduino yun successor
arduino yun python
arduino yun manual

I am trying to have a nodejs application start automatically on system boot. Basically all I need is to run the command node /dir/app. I am using openwrt on an Arduino Yun. And have tried a couple things.

On the openwrt website it said I can do this. https://wiki.openwrt.org/inbox/procd-init-scripts :

#!/bin/sh /etc/rc.common
USE_PROCD=1
start_service() {
  procd_open_instance
  procd_set_param command node ///www/www-blink.js
  procd_close_instance
}

I have also tried changing the dir to /www/www-blink.js not ///

However i'm not sure what i'm doing wrong as nothing comes up when I try run it with /etc/init.d/node-app start I am obviously writing the code wrong but i'm not sure what it should exactly look like.

The other thing I have tried is the node modules forever and forever-service. I downloaded them on my computer using npm install -g forever and forever-service aswell. I transfered them to usr/lib/node_modules on my arduino yun. However when I try to use and forever(-service) commands it says

-ash: forever: not found

I have tried a couple other things, however nothing has worked. Any help would be greatly appreciated.

-- I also need to be able to start my express script with npm start not node app but I guess the first thing is getting it to work at all.

you can put the starting command (node /dir/app &)in the /etc/rc.local script. This will start your nodejs application automatically on system boot.

How to automatically start a program on boot on the arduino yun, How to automatically start a program on boot on the arduino yun. website it said I can do this. https://wiki.openwrt.org/inbox/procd-init-scripts : write it as nothing comes up when I try run it with `/etc/init.d/node-app start` I am  You can work around this problem by installing the firmata package on your own system and copy the node_modules directory from your system to the SD-card. Just pull your SD-card out of the Yun and plug it into your computer. You will find node_modules directory in the arduino folder.

OpenWRT procd has a "respawn" parameter, which will restart a service that exits or crashes.

# respawn automatically if something died, be careful if you have an 
# alternative process supervisor if process dies sooner than respawn_threshold,
# it is considered crashed and after 5 retries the service is stopped

procd_set_param respawn ${respawn_threshold:-3600} ${respawn_timeout:-5} ${respawn_retry:-5}

So, you cold just add: procd_set_param respawn 60 5 5

or something like that to your OpenWRT procd initscript. This 60 5 5 means it will wait 5s between respawns (middle parameter), and if it respanws more than 5 times (last parameter) in 60s (first parameter), it will disable the service ("restart loop" detected).

Refer to this page for more information: https://openwrt.org/docs/guide-developer/procd-init-scripts

Getting Started with the Arduino Yún an Yún Mini LininoOS, OpenWrt LininoOS; Install additional software on Linux; Python Connect your Yún or Yún mini and the drivers will be installed automatically You can simply write your application using Node.js, Python, Bash, etc., on linux  Sponsor arduino/openwrt-packages-yun Watch 34 Star 65 Fork 53 Code. Issues 5. Pull Sqlite3 with node.js #20. tslater opened this issue Oct 24, 2014 · 7 comments

You need to execute your node application like a Linux Service.

Upstart is perfect for this task

Upstart is an event-based replacement for the /sbin/init daemon which handles starting of tasks and services during boot, stopping them during shutdown and supervising them while the system is running.

If you have an app like this (for example):

// app.js
var express = require('express')  
var app = express()  
var port = process.env.PORT

app.get('/', function(req, res) {  
  res.send('Hello world!')
})

app.listen(port)

With a package.json like this:

{
  "name": "my-awesome-app",
  "version": "1.0.0",
  "dependencies": {
     "express": "^4.13.3"
  },
  "scripts": {
     "start": "node app.js"
  }
}

We create a upstart configuration file called myAwesomeApp.conf with the following code:

start on runlevel [2345]  
stop on runlevel [!2345]

respawn  
respawn limit 10 5

setuid ubuntu  
chdir /opt/myAwesomeApp.conf

env PORT=3000

exec npm start 

To finish, put your application (app.js and package.json) in the /opt/myAwesomeApp.conf and copy the configuration file myAwesomeApp.conf in /etc/init/

This is all, now you just need to run service myAwesomeApp start to run your node application as a service

How+to+start+nodejs+application+automatically+on+openwrt+ , I am trying to have a nodejs application start automatically on system boot. Basically all I need is to run the command node /dir/app . I am using  However i'm not sure what who to exactly write it as nothing comes up when I try run it with /etc/init.d/node-app start I am obviously writing the code wrong but i'm not sure what it should exactly look like, It would be great if someone could provide an example.

I've never used procd before, but it likely needs the full path to node (e.g., /usr/bin/node). You'd need to make the line something like procd_set_param command /usr/bin/node /www/www-blink.js, assuming the file you want to run is /www/www-blink.js. You can locate node by running which node or type -a node.

Openwrt discord, OpenWRT-dist is an open source application. I am trying to have a nodejs application start automatically on system boot. Overview of the Arduino Yun. Searching for installation instructions, bootlogs, other info? See link to Device Page below.

Arduino Yun, Вы можете поместить стартовую команду (node ​​/ dir/app &) в сценарий /​etc/rc.local. Это автоматически запустит приложение nodejs при загрузке  Select your board type and port. You'll need to select the entry in the Tools > Board menu that corresponds to your Arduino Yún or Yún mini board. Select the serial device of the board from the Tools | Serial Port menu. This is likely to be COM3 or higher ( COM1 and COM2 are usually reserved for hardware serial ports).

Arduino YUN with Cylon.js, JS on the OpenWRT side of the YUN to talk to Firmata on the Arduino side, we'll need to install node-serialport. There's a precompiled package available, and  Wed 16 October 2013 | Category: Blog | arduino yun nodejs. Since few weeks I was looking for a web environment to develop an IDE for the YUN. I already compiled an avr toolchain but I was not happy with a python based app server, since it makes difficult to handle websockets in an async fashion and so.

It seems like client side mdns is hard to get to work on the yun at the moment. If you take a look at arduino/openwrt-yun#7 there are tools but no libs for using mdns. Things may change in the future: latest OpenWrt (14.07, RC3 at the time of writing) mentions. mdns: new lightweight mdns daemon (work in progress)

Comments
  • stackoverflow.com/questions/11275870/…
  • How would I install upstart onto the arduino yun?
  • Upstart has largely been replaced by systemd.
  • Tried this. However it still said nothing or showed no processes when I used top. I used /etc/init.d/node-app start and also tried /etc/init.d/node-app enable with a START=1