Autostart - control your processes with supervisor

Hello,

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
[program:arducopter]
command=ArduCopter-hexa -A udp:127.0.0.1:14550
priority=20
autostart=true
autorestart=true
stderr_logfile=/var/log/arducopter.err.log
stdout_logfile=/var/log/arducopter.out.log

$ cat /etc/supervisor/conf.d/mavproxy.conf
[program:mavproxy]
command=/usr/local/bin/mavproxy.py --master=127.0.0.1:14550 --logfile=mav.log --out=192.168.0.20:14550 --out=192.168.0.29:14550
priority=10
autostart=true
autorestart=true
stderr_logfile=/var/log/mavproxy.err.log
stdout_logfile=/var/log/mavproxy.out.log

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

http://supervisord.org/

3 Likes

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:192.168.1.15:14550 -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
No

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