Particle Pi Agent
This program supervises the Particle firmware executable running on Raspberry Pi.
Architecture
Particle Pi is a Ruby application. The logic lives inside
The Agent is an executable that runs as a background service (daemon).
The agent executable is
The service description for the Agent is a System V init script in
Installing the service
sudo cp init/particlepi /etc/init.d
sudo ln -s $PWD/bin/agent /usr/local/bin/particlepi-agent
sudo insserv particlepi
After updating the init/particlepi
script run:
sudo systemctl daemon-reload
Note: update-rc.d
is deprecated. Use insserv
instead.
Start the service
sudo service particlepi start
Other commands:
$ sudo service particlepi
Usage: /etc/init.d/particlepi {start|stop|restart|status}
Releasing software to a Debian personal package archive (PPA)
Our PPA is https://launchpad.net/~particleio/+archive/ubuntu/particlepi
- Create an account on Launchpad
- Create a team on Launchpad
- Create a PPA on Launchpad https://help.launchpad.net/Packaging/PPA/BuildingASourcePackage
- Upload a source package to Launchpad https://help.launchpad.net/Packaging/PPA/Uploading
- Launchpad will build your package
To get added to the Launchpad team, launch https://launchpad.net/people/+me, register an account and ask one of the existing team members to add you to the particleio team.
Development notes
Communicate with child processes https://www.rubytapas.com/2016/06/16/episode-419-subprocesses-part-4-redirection/
` input, output = IO.pipe
pid = Process.spawm "exec", "arg", out: output
Process.waitpid(pid) input.close input.read `
` rd, wr = IO.pipe
if fork wr.close puts "Starting read" puts "Parent got: <#rdrd.read>" rd.close Process.wait else rd.close sleep 1 puts "Sending message to parent" wr.write "Hi Dad" wr.close end `
Trap SIGCHLD when child exits https://www.rubytapas.com/2016/06/30/episode-423-subprocesses-part-5-sigchld/
trap("CHLD") do
pid = Process.waitpid(-1)
pids[pid] = :done
end