particle-iot/particle-agent

Name: particle-agent

Owner: Particle

Description: Agent supervising the Particle firmware on the Raspberry Pi

Created: 2016-10-11 20:59:00.0

Updated: 2018-02-11 22:44:18.0

Pushed: 2018-01-03 18:36:52.0

Homepage:

Size: 771

Language: Ruby

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

Particle Agent Build Status

This program supervises the Particle firmware executable running on Raspberry Pi.

Installing

Install the particle-agent Debian package by running this command on your Raspberry Pi:

 <( curl -sL https://particle.io/install-pi )
Architecture

Particle Agent is a Ruby application. The logic lives inside

The Agent service is an executable that runs as a background service (daemon). The agent service executable is and does things like command line parsing. It delegates to the Daemon class to manage a PID file, a log file and fork the process to the background.

The logic for the agent is in the Agent class. It finds which firmware executables should run and runs them in their own process, restarting them if they stop.

The service description for the Agent service is a System V init script in .

Manually Installing the service

FIXME: These instructions may not apply anymore

 cp debian/particle-agent.init /etc/init.d
 ln -s $PWD/bin/particle-agent-service /usr/bin/particle-agent-service
 insserv particle-agent

After updating the init script run:

 systemctl daemon-reload

Note: update-rc.d is deprecated. Use insserv instead.

Interacting with the service
Starting
 service particle-agent start
Stopping
 service particle-agent stop
See what's running
 service particle-agent status
View logs
/var/log/particle-agent.log
Development

After checking out the repo, run bin/setup to install dependencies. Then, run rake test to run the tests.

TODO: the following may not be accurate.

To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and tags, and push the .gem file to rubygems.org.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/spark/particlepi.

Building a Debian package

Prerequisites:

If gem is released to RubyGem, run

deb -p particle-agent particle-agent

Or build the gem locally

build *.gemspec
deb -p particle-agent *.gem
Development notes

Communicate with child processes https://www.rubytapas.com/2016/06/16/episode-419-subprocesses-part-4-redirection/

t, output = IO.pipe

= Process.spawn "exec", "arg", out: output

ess.waitpid(pid)
t.close
t.read
wr = IO.pipe

ork
.close
ts "Starting read"
ts "Parent got: <#{rd.read}>"
.close
ocess.wait

.close
eep 1
ts "Sending message to parent"
.write "Hi Dad"
.close

Trap SIGCHLD when child exits https://www.rubytapas.com/2016/06/30/episode-423-subprocesses-part-5-sigchld/

("CHLD") do
d = Process.waitpid(-1)
ds[pid] = :done


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.