CodeLabs
  • Introduction
  • Cities
    • Cover
    • Summary
    • Introduction
      • Getting Started
      • Resources
      • Naming Convention
    • Caracol
      • Architecture
        • Intel
        • Operating Systems
        • Hardware Platform
        • Field Requirements
        • Software Development
        • Video Conference Station
          • Applications
          • Entertainment System
            • Services
              • Graphics
              • Video
              • Camera
              • Text To Speech
              • Speech To Text
              • Photography
              • Gaming
                • Super Nintendo Emulators
                • Super Nintendo ROMs
              • Twitter
              • Keyboard
              • Google Drive
              • WiFi
            • Modules
            • Tbd
        • Functionality
        • Bill Of Materials
        • Open Questions
        • Future
    • Chacmultun
      • JHD1313M1
        • Background
          • Inter-Integrated Circuit
          • Linux I2C Subsystem
        • Device Drivers
          • User Space Library UPM
          • User Space Library MRAA
          • User Space I2C Library
          • Kernel Space I2C Driver
    • Chicanna
      • OpenCV
        • Face Recognition
        • Web Streaming
    • Chichen Itza
      • Audio
        • Advanced Linux Sound Architecture
        • PortAudio
        • PyAudio
          • Record
          • Play
      • Text To Speech
        • eSpeak
          • pyttsx
        • VoiceRss
          • VoiceRss Text To Speech Python SDK
      • Speech To Text
        • CMU Sphinx
          • Sphinx Knowledge Base Tool
          • PocketSphinx
          • PyAudio
        • SpeechRecognition
    • Coba
      • Linux Kernel Source Code
        • Git Source Code Management
      • Linux Kernel Development Process
        • A Guide To The Linux Kernel Development Process
        • Challenge
      • Linux Kernel Compilation
      • Linux Kernel Modules
      • Linux Kernel Build System
        • Compilation Kernel Object
        • Compilation Built-In
      • Linux Kernel Patch
        • Patchset
      • Linux Kernel Developer
      • Learn More
    • Dos Pilas
    • Dzibilchaltun
    • Edzna
      • MQ Telemetry Transport
        • MQTT Broker
      • Home Assistant
        • Setup
        • Default Configuration
        • Hello
      • Home Automation
        • Device
          • Light ESP8266
          • Intel Edison
        • Server
          • MQTT
            • Light
            • Sensor
            • Binary Sensor
            • Alarm
          • Dweet
          • Weather
          • Binary Sensor
          • Telegram
          • Camera
          • Automation
      • Shack Automation
        • Configuration Yaml
    • Ek Balam
      • Google Cloud Platform
        • Google API Keys
        • Google Application Default Credentials
      • Google Cloud Translation API
      • Google Cloud Vision API
      • Google Cloud Speech
    • Hochob
      • Introduction
      • Accounts
      • Areas
        • Naming Conventions
      • Digital Media Players
        • Chromecast
      • Keypads
      • Mobile Device
      • Amikoo
        • Architecture
          • Hardware Components
            • Intel® Edison Breakout Board
        • Amikoo
          • Setup
          • Git Repositories
          • Audio
          • Main Intel Edison
          • Main x86
        • Sandbox
          • Tbd
      • Server
        • Setup
          • Root
          • PulseAudio
        • Architecture
        • Media
        • Services
          • Automation
            • Home Assistant
              • Setup
          • Calendar
          • Camera
          • Communications
          • Games
            • Loteria Mexicana
            • Caras Y Gestos
            • Sopa De Letras
          • Image
          • Institution
          • Keypad
          • Messaging
          • Motion
          • Robot
          • Sound
            • Play
            • Speech Synthetizer
          • Stream
          • Usb
          • Survey
        • Applications
          • Captain Maya Lands
          • Southern Maya Highlands
          • Amikoo Maya Lands
          • Central Maya Lowlands
          • Northern Maya Lowlands
          • Console Maya Lands
          • Media Maya Lands
          • Calendar Maya Lands
          • Tradition Maya Lands
          • Techie Maya Lands
          • NohochTata Maya Lands
      • Stations
      • Architecture
      • Release Notes
        • v0.1
        • v0.2
    • Hormiguero
    • Kaminaljuyu
      • WRI Workshop
        • Environmental Protection Agency
      • Arquitecture
        • Bill Of Materials
      • Intel
    • Kanki
      • Device
      • Gateway
    • Kinich KaK Moo
    • Kohunlich
    • La Ruta Puuc
    • Mayapan
    • Mixco Viejo
    • Muyil
    • Palenque
    • Qumarkaj
      • Amazon
      • Amazon Echo
        • Lifx
        • IFTTT
      • Amazon Alexa
        • Alexa Skills Kit
          • Training: Developing Alexa Skills - Hello, Alexa!
          • Training: Alexa - A Free Introduction
          • Projects
            • Intel GDC Visitor Center
              • Cloudy
              • Geek
              • Trivia
              • Kit
            • Voice Control Intel Edison
        • Alexa Voice Service
          • Intel Edison
    • Seibal
    • Tabasqueno
    • Tikal
      • Mexican Red Cross
      • Emergency Medical Services
        • Prehospital Care Strategies
      • Intel
      • Bitalino
      • My Signals
      • Architecture
        • Objectives
    • Tulum
      • Introduction
      • Device
        • Development Board
        • Telegram Bot
        • Bootup
        • Text Editors
        • Setup
        • Main
        • IoT101 Inc
        • Mqtt Clients
        • Sensors
      • Server
        • Setup
        • Dashboard
        • Mqtt Broker
      • Challenge
    • Uxmal
    • Xcambo
    • Xpuhil
    • Xunantunich
    • Sandbox
      • Text To Speech
      • Face Recognition Web Streaming
      • Web Server Flask
      • Speech To Text
      • Image Webpage Flask
      • Audio Capture Playback
      • Image Capture OpenCV
    • Tbd
      • Tbd
      • Linux Kernel Architecture
      • Linux Kernel Device Drivers
      • Tbd
  • Gods
    • Acat
      • Node-RED
        • Installation
          • General
          • Base
          • Npm Packages
          • Node-RED Packages
        • Autostart
      • Projects
        • GPIO
        • MQTT
        • Intel GDC Visitor Center
      • Sandbox
    • Ah Puch
      • Recon Instruments
        • ReconJet
          • Get Started
        • ReconEngage
        • Uplink
        • Intel Developer Zone
          • Recon Dev Kit for Jet™
      • Bicycles
    • Akna
      • Hardware
        • Intel Edison
        • Sphero
        • Bluetooth Dongle
      • Software
        • Javascript
        • Cylon.js
          • Cylon.js Intel Edison
          • Cylon.js Intel Edison Sphero
            • Examples
        • Sphero Linux API
    • Alom
    • Bacab
      • Getting Started
        • Inventory
        • Accounts
        • Software
      • Proof Of Concepts
        • Doorbell
    • Bitol
      • Drone Software Development Environment
        • PX4
        • JMAVSim
        • Ardupilot
        • SITL Simulator
        • DroneKit
        • QGroundControl
        • MAVLink
        • OpenCV
        • Git Source Code Management
      • Drone Solution Architect
        • Companies
      • Dronecode Project
      • Base Drone Solution
        • Flight Controller Hardware
          • PixHawk
          • Intel® Aero Ready to Fly Drone
          • Emlid
          • Erle Brain
        • Flight Controller Operating System
        • Autopilot
          • Px4
            • Architecture
              • NuttX
              • DriverFramework
            • Shell
          • Ardupilot
          • Software In The Loop
            • jMAVSim
            • DroneKit SITL
        • Communications
          • Mavlink
            • PyMAVLink
        • Ground Control Station
          • QGroundControl
        • Developer APIs
      • Hybrid Drone Solution
      • Autonomous Drone Solution
      • Drone Solutions
        • Erle Robotics
        • Emlid
      • Training
        • Drone Solution Architect
          • Demos
            • Ka’an
            • Múuyal
            • lik’
            • Chak iik’
    • Chaac
    • Bolon Ts'akab
    • Buluc Chabtan
      • Challenge
    • Chaac Uayab Xoc
    • Cacoch
      • Background
        • Open Source
        • Do It Yourself Communities
      • The Project
        • History
        • Career Profile
        • Education Strategy
        • Courses
        • Infrastructure
Powered by GitBook
On this page
  • Autostart
  • pm2 :)
  • node-red Start
  • Crontab
  1. Gods
  2. Acat
  3. Node-RED

Autostart

Autostart

pm2 :)

root@edison:~# npm install -g --unsafe-perm pm2

node-red Start

root@edison:~# pm2 start /usr/bin/node-red --node-args="--max-old-space-size=256"
��┌��─��─��─��─��─��─��─��─��─��─��┬��─��─��─��─��─��─��┬��─��─��─��─��─��─��─��─��┬��─��─��─��┬��─��─��─��─��─��┬��─��─��─��─��─��─��─��─��┐
��│ Name     ��│ mode ��│ status ��│ ��↺ ��│ cpu ��│ memory    ��│
��├��─��─��─��─��─��─��─��─��─��─��┼��─��─��─��─��─��─��┼��─��─��─��─��─��─��─��─��┼��─��─��─��┼��─��─��─��─��─��┼��─��─��─��─��─��─��─��─��┤
��│ node-red ��│ fork ��│ online ��│ 1 ��│ 0%  ��│ 34.3 MB   ��│
��└��─��─��─��─��─��─��─��─��─��─��┴��─��─��─��─��─��─��┴��─��─��─��─��─��─��─��─��┴��─��─��─��┴��─��─��─��─��─��┴��─��─��─��─��─��─��─��─��┘
 Use `pm2 show <id|name>` to get more details about an app

node-red Restart

root@edison:~# pm2 restart node-red
Use --update-env to update environment variables
[PM2] Applying action restartProcessId on app [node-red](ids: 0)
[PM2] [node-red](0) ��✓
��┌��─��─��─��─��─��─��─��─��─��─��┬��─��─��─��─��─��─��┬��─��─��─��─��─��─��─��─��┬��─��─��─��┬��─��─��─��─��─��─��┬��─��─��─��─��─��─��─��┐
��│ Name     ��│ mode ��│ status ��│ ��↺ ��│ cpu  ��│ memory   ��│
��├��─��─��─��─��─��─��─��─��─��─��┼��─��─��─��─��─��─��┼��─��─��─��─��─��─��─��─��┼��─��─��─��┼��─��─��─��─��─��─��┼��─��─��─��─��─��─��─��┤
��│ node-red ��│ fork ��│ online ��│ 2 ��│ 100% ��│ 3.1 MB   ��│
��└��─��─��─��─��─��─��─��─��─��─��┴��─��─��─��─��─��─��┴��─��─��─��─��─��─��─��─��┴��─��─��─��┴��─��─��─��─��─��─��┴��─��─��─��─��─��─��─��┘
 Use `pm2 show <id|name>` to get more details about an app

node-red Autostart, Working

root@edison:/etc/init.d# ls
fuse  node-red.sh
root@edison:/etc/init.d# update-rc.d node-red.sh defaults                                                                                                      
 Adding system startup for /etc/init.d/node-red.sh.
root@edison:/etc/init.d#

node-red Autostart, Not Working

root@edison:~# nano node-red.sh
pm2 start /usr/bin/node-red --node-args="--max-old-space-size=256"
root@edison:~# chmod +x node-red.sh 
root@edison:~# cd /lib/systemd/system
root@edison:/lib/systemd/system# nano node-red.service
[Unit]
Description=Node-RED   
After=sys-subsystem-net-devices-%i.device

[Service]
ExecStart=/bin/sh /home/root/node-red.sh
Restart=always
RestartSec=10

[Install]
Alias=NodeRed   
WantedBy=multi-user.target
root@edison:/lib/systemd/system# systemctl daemon-reload
root@edison:/lib/systemd/system# systemctl --system enable node-red
ln -s '/lib/systemd/system/node-red.service' '/etc/systemd/system/NodeRed'
ln -s '/lib/systemd/system/node-red.service' '/etc/systemd/system/multi-user.target.wants/node-red.service'
root@edison:/lib/systemd/system# systemctl start node-red
root@edison:/lib/systemd/system# systemctl status node-red.service -l
��● node-red.service - Node-RED
   Loaded: loaded (/lib/systemd/system/node-red.service; enabled)
   Active: active (running) since Sun 2017-03-12 22:59:54 UTC; 1s ago
 Main PID: 479 (bash)
   CGroup: /system.slice/node-red.service
           ��├��─479 /bin/bash /home/root/node-red.sh
           ��└��─480 node /usr/bin/node-red

Mar 12 22:59:54 edison systemd[1]: Started Node-RED.

node-red Autostart, Not Working

root@edison:~# cd /etc/init.d/
root@edison:/etc/init.d# pm2 save
[PM2] Saving current process list...
[PM2] Successfully saved in /home/root/.pm2/dump.pm2
root@edison:/etc/init.d# pm2 startup
[PM2] Init System found: systemd
Platform systemd
Template
[Unit]
Description=PM2 process manager
Documentation=https://pm2.keymetrics.io/
After=network.target

[Service]
Type=forking
User=root
LimitNOFILE=infinity
LimitNPROC=infinity
LimitCORE=infinity
TimeoutStartSec=8
Environment=PATH=/usr/bin:/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin
Environment=PM2_HOME=/home/root/.pm2
PIDFile=/home/root/.pm2/pm2.pid

ExecStart=/usr/lib/node_modules/pm2/bin/pm2 resurrect
ExecReload=/usr/lib/node_modules/pm2/bin/pm2 reload all
ExecStop=/usr/lib/node_modules/pm2/bin/pm2 kill

[Install]
WantedBy=multi-user.target

Target path
/etc/systemd/system/pm2-root.service
Command list
[ 'chmod +x /etc/systemd/system/pm2-root.service',
  'systemctl enable pm2-root',
  'systemctl start pm2-root',
  'systemctl daemon-reload',
  'systemctl status pm2-root' ]
[PM2] Writing init configuration in /etc/systemd/system/pm2-root.service
[PM2] Making script booting at startup...
>>> Executing chmod +x /etc/systemd/system/pm2-root.service
[DONE] 
>>> Executing systemctl enable pm2-root
ln -s '/etc/systemd/system/pm2-root.service' '/etc/systemd/system/multi-user.target.wants/pm2-root.service'
[DONE] 
>>> Executing systemctl start pm2-root
[DONE] 
>>> Executing systemctl daemon-reload
[DONE] 
>>> Executing systemctl status pm2-root
��● pm2-root.service - PM2 process manager
   Loaded: loaded (/etc/systemd/system/pm2-root.service; enabled)
   Active: active (running) since Sun 2017-03-12 18:55:52 UTC; 660ms ago
     Docs: https://pm2.keymetrics.io/
 Main PID: 2612 (PM2 v2.4.2: God)
   CGroup: /system.slice/pm2-root.service
           ��‣ 2612 PM2 v2.4.2: God Daemon (/home/root/.pm2)             

Mar 12 18:55:51 edison pm2[2701]: [PM2] Resurrecting
Mar 12 18:55:51 edison pm2[2701]: [PM2] Restoring processes located in /home/root/.pm2/dump.pm2
Mar 12 18:55:52 edison pm2[2701]: ��┌��─��─��─��─��─��─��─��─��─��─��┬��─��─��─��─��┬��─��─��─��─��─��─��┬��─��─��─��─��─��─��┬��─��─��─��─�┐
Mar 12 18:55:52 edison pm2[2701]: ��│ App name ��│ id ��│ mode ��│ pid  ��│ status ��│ restart ��│ uptime ��│ cpu ��│ mem       ��│ watching│
Mar 12 18:55:52 edison pm2[2701]: ��├��─��─��─��─��─��─��─��─��─��─��┼��─��─��─��─��┼��─��─��─��─��─��─��┼��─��─��─��─��─��─��┼��─��─��─��─�┤
Mar 12 18:55:52 edison pm2[2701]: ��│ node-red ��│ 0  ��│ fork ��│ 2656 ��│ online ��│ 1       ��│ 5m     ��│ 0%  ��│ 34.0 MB   ��│ disabled│
Mar 12 18:55:52 edison pm2[2701]: ��└��─��─��─��─��─��─��─��─��─��─��┴��─��─��─��─��┴��─��─��─��─��─��─��┴��─��─��─��─��─��─��┴��─��─��─��─�┘
Mar 12 18:55:52 edison pm2[2701]: Use `pm2 show <id|name>` to get more details about an app
Mar 12 18:55:52 edison systemd[1]: Started PM2 process manager.
[DONE] 
+---------------------------------------+
[PM2] Freeze a process list on reboot via:
$ pm2 save

[PM2] Remove init script via:
$ pm2 unstartup systemd
root@edison:/etc/init.d#
root@edison:/etc/init.d# pm2 startup systemd
[PM2] Init System found: systemd
Platform systemd
Template
[Unit]
Description=PM2 process manager
Documentation=https://pm2.keymetrics.io/
After=network.target

[Service]
Type=forking
User=root
LimitNOFILE=infinity
LimitNPROC=infinity
LimitCORE=infinity
TimeoutStartSec=8
Environment=PATH=/usr/bin:/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin
Environment=PM2_HOME=/home/root/.pm2
PIDFile=/home/root/.pm2/pm2.pid

ExecStart=/usr/lib/node_modules/pm2/bin/pm2 resurrect
ExecReload=/usr/lib/node_modules/pm2/bin/pm2 reload all
ExecStop=/usr/lib/node_modules/pm2/bin/pm2 kill

[Install]
WantedBy=multi-user.target

Target path
/etc/systemd/system/pm2-root.service
Command list
[ 'chmod +x /etc/systemd/system/pm2-root.service',
  'systemctl enable pm2-root',
  'systemctl start pm2-root',
  'systemctl daemon-reload',
  'systemctl status pm2-root' ]
[PM2] Writing init configuration in /etc/systemd/system/pm2-root.service
[PM2] Making script booting at startup...
>>> Executing chmod +x /etc/systemd/system/pm2-root.service
[DONE] 
>>> Executing systemctl enable pm2-root
[DONE] 
>>> Executing systemctl start pm2-root
[DONE] 
>>> Executing systemctl daemon-reload
[DONE] 
>>> Executing systemctl status pm2-root
��● pm2-root.service - PM2 process manager
   Loaded: loaded (/etc/systemd/system/pm2-root.service; enabled)
   Active: active (running) since Sun 2017-03-12 21:44:32 UTC; 949ms ago
     Docs: https://pm2.keymetrics.io/
 Main PID: 421 (PM2 v2.4.2: God)
   CGroup: /system.slice/pm2-root.service
           ��‣ 421 PM2 v2.4.2: God Daemon (/home/root/.pm2)             

Mar 12 21:44:32 edison pm2[598]: [PM2] Resurrecting
Mar 12 21:44:32 edison pm2[598]: [PM2] Restoring processes located in /home/root/.pm2/dump.pm2
Mar 12 21:44:32 edison pm2[598]: ��┌��─��─��─��─��─��─��─��─��─��─��┬��─��─��─��─��┬��─��─��─��─��─��─��┬��─��─��─��─��─��┬��─��─��─��─��─��┐
Mar 12 21:44:32 edison pm2[598]: ��│ App name ��│ id ��│ mode ��│ pid ��│ status ��│ restart ��│ uptime ��│ cpu ��│ mem       ��│ watching �│
Mar 12 21:44:32 edison pm2[598]: ��├��─��─��─��─��─��─��─��─��─��─��┼��─��─��─��─��┼��─��─��─��─��─��─��┼��─��─��─��─��─��┼��─��─��─��─��─��┤
Mar 12 21:44:32 edison pm2[598]: ��│ node-red ��│ 0  ��│ fork ��│ 573 ��│ online ��│ 7       ��│ 11s    ��│ 79% ��│ 34.9 MB   ��│ disabled �│
Mar 12 21:44:32 edison pm2[598]: ��└��─��─��─��─��─��─��─��─��─��─��┴��─��─��─��─��┴��─��─��─��─��─��─��┴��─��─��─��─��─��┴��─��─��─��─��─��┘
Mar 12 21:44:32 edison pm2[598]: Use `pm2 show <id|name>` to get more details about an app
Mar 12 21:44:32 edison systemd[1]: Started PM2 process manager.
[DONE] 
+---------------------------------------+
[PM2] Freeze a process list on reboot via:
$ pm2 save

[PM2] Remove init script via:
$ pm2 unstartup systemd
root@edison:/etc/init.d#
root@edison:/etc/init.d# cd
root@edison:~#

Crontab

root@edison:~# opkg install cronie
Installing cronie (1.4.11-r0) on root.
Downloading http://iotdk.intel.com/repos/3.5/iotdk/edison/core2-32/cronie_1.4.11-r0_core2-32.ipk.
Installing pam-plugin-access (1.1.6-r5) on root.
Downloading http://iotdk.intel.com/repos/3.5/iotdk/edison/core2-32/pam-plugin-access_1.1.6-r5_core2-32.ipk.
Running groupadd commands...
NOTE: Performing groupadd with [ --system crontab] and 10 times of retry
Configuring pam-plugin-access.
Configuring cronie.
ln -s '/lib/systemd/system/crond.service' '/etc/systemd/system/multi-user.target.wants/crond.service'
root@edison:~#
systemctl status pm2-root.service
echo $?
pm2 restart node-red
PreviousNode-RED PackagesNextProjects

Last updated 7 years ago

http://askubuntu.com/questions/676007/how-do-i-make-my-systemd-service-run-via-specific-user-and-start-on-boot