Skip to content

Instantly share code, notes, and snippets.

@jadonk
Last active June 22, 2016 14:44
Show Gist options
  • Save jadonk/ad049193593539cea29e to your computer and use it in GitHub Desktop.
Save jadonk/ad049193593539cea29e to your computer and use it in GitHub Desktop.
Starting node-red on BeagleBone Black running shipping Debian distro
#!/bin/sh
npm install -g node-red@0.9.1-nocolors
cp $(dirname $0)/node-red.socket $(dirname $0)/node-red.service /lib/systemd/system/
cat $(dirname $0)/node-red.patch | ( cd /usr/local/lib/node_modules/node-red ; patch -p1 )
cp $(dirname 0)/node-red.sh /usr/local/lib/node_modules/node-red/
systemctl enable node-red.socket
systemctl start node-red.socket
diff -rupN original/red.js new/red.js
--- original/red.js 2014-11-10 02:05:33.433249478 +0000
+++ new/red.js 2014-11-10 02:06:38.999655735 +0000
@@ -21,6 +21,7 @@ var crypto = require("crypto");
var nopt = require("nopt");
var path = require("path");
var RED = require("./red/red.js");
+require('bonescript/node_modules/systemd');
var server;
var app = express();
@@ -182,7 +183,8 @@ RED.start().then(function() {
}
process.exit(1);
});
- server.listen(settings.uiPort,settings.uiHost,function() {
+ server.listen(settings.uiPort);
+ server.on('listening', function() {
if (settings.httpAdminRoot === false) {
util.log('[red] Admin UI disabled');
}
diff -rupN original/settings.js new/settings.js
--- original/settings.js 2014-11-10 02:08:45.419577625 +0000
+++ new/settings.js 2014-11-10 02:10:02.405905760 +0000
@@ -13,9 +13,12 @@
* See the License for the specific language governing permissions and
* limitations under the License.
**/
+
+var port = process.env.LISTEN_PID > 0 ? 'systemd' : 1880;
+
module.exports = {
// the tcp port that the Node-RED web server is listening on
- uiPort: 1880,
+ uiPort: port,
// By default, the Node-RED UI accepts connections on all IPv4 interfaces.
// The following property can be used to listen on a specific interface. For
@@ -121,7 +124,7 @@ module.exports = {
functionGlobalContext: {
// os:require('os'),
- // bonescript:require('bonescript'),
+ bonescript:require('bonescript'),
// arduino:require('duino')
}
[Unit]
Description=Start Node-RED
[Service]
Environment=HOME=/root
WorkingDirectory=/root
ExecStart=/usr/local/lib/node_modules/node-red/node-red.sh
SyslogIdentifier=Node-RED
RemainAfterExit=yes
[Install]
WantedBy=multi-user.target
#!/bin/bash -
export NODE_PATH=/usr/local/lib/node_modules
cd /usr/local/lib/node_modules/node-red/
/usr/bin/node --max-old-space-size=128 red.js
[Socket]
ListenStream=1880
[Install]
WantedBy=sockets.target
@mitchmitchell
Copy link

It looks like the line "cp $(dirname 0)/node-red.sh /usr/local/lib/node_modules/node-red/" is missing a '$' character in front of the '0' in the file install-node-red.sh

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment