Autostart - control your processes with supervisor


There are a ton of ways to control the arducopter process on your rpi2. Many solutions have been shared on the forum already, but I haven’t seen anyone mention this method so I thought I would share with you what I use to control key processes on my rpi2.
It’s called supervisor.
You can install it like so:
sudo apt-get install supervisor

I then have these files for arducopter and mavproxy:

$ cat /etc/supervisor/conf.d/arducoper.conf
command=ArduCopter-hexa -A udp:

$ cat /etc/supervisor/conf.d/mavproxy.conf
command=/usr/local/bin/ --master= --logfile=mav.log --out= --out=

It’s very flexible and you can even control it remotely via an api (without having to ssh).


Nice, but how does that compare to the “standard” (being careful as I am not a Linux expert) service config? Thought that would also restart. Quite concerned about that. Even though I have not had a (software) crash yet, if it did happen it would be nice to know there was the best chance of APM re-initializing before it hits the ground. If this solution is better than standard I’ll take it (just good to know why).

Ok … I wonder will it sort out my problem.
I try to make ArduCopter autostart in background.
My rc.local row is
sudo ArduCopter-quad -A udp: -C /dev/ttyAMA0
when I put “&” on the end only udp works.
I am unable also to call -C /dev/ttyAMA0, yesteday it worked but auto start didn’t…

pi@navio:~ $ sudo ArduCopter-quad -C /dev/ttyAMA0
Raspberry Pi 2 with BCM2709!

Init APM:Copter V3.4-dev (056dc9f3)

Free RAM: 262144
FW Ver: 120

load_all took 313us
/sys/kernel/rcio/adc/ch255 not opened: No such file or directory

Hi Tony,

Well an “init.d” script won’t restart the process if it crashes, while a “systemd” or an “upstart” script could restart the process. I think the scripts I saw on the forum were “init.d” here .
Having your start command in rc.local won’t restart the process if it crashes either.
To test it out simply kill the process with
kill -9 "your_pid"
and check if it restarts by itself.

Supervisor will monitor your process and restart it if it crashes, but that’s not the main reason I am using it - I was looking for a way to manage the processes remotely without ssh, My goal is to have a web page were I can change the ip and udp port of arducopter and restart the process through that. I don’t want to have to ssh on the field.

Robert, I believe the console is enabled by default on the serial port. I believe you have to disable it with:

sudo raspi-config
Advanced options
A8 Serial

I use monit for process monitoring.
Nevertheless, you are right systemd is the future.