Start edged On Boot

Intro

ExoEdge is Exosite’s officially supported client to ExoSense.

There are several ways to make sure the edged process(es) on your gateway start on boot and keep them running.

Supervisor

The supervisord tool is handy because it makes sure your processes start on boot, stay running and it takes care of rotating the edged log file.

Install supervisord:

sudo su
apt-get install supervisor --yes

Define the edged config file for supervisord

echo '[program:edged]
command = edged -i /var/config/edged.ini -c /var/config/edged.json go 
autostart = true
autorestart = true
stdout_logfile = /var/log/edged.log
stdout_logfile_maxbytes = 1MB
redirect_stderr = true
' > /etc/supervisor/conf.d/edged.conf

Reboot

reboot

or reload supervisord

supervisorctl reload

Your gateway will now start edged on boot as well as rotate its log file.

SysV

Copy this SysV Init Script onto your gateway and execute the following commands.

cp edged /etc/init.d/
chmod 755 /etc/init.d/edged
chown root:root /etc/init.d/edged
update-rc.d edged defaults 90 90

Now, make sure you set up your gateway to rotate the edged logfile.

echo '/var/log/edged.log {
    rotate 3
    maxsize 1M
}' >> /etc/logrotate.conf

crontab -l > tmp
echo -e '* * * * *\t\tlogrotate' >> tmp
crontab tmp

Now, crontab will call logrotate every minute to keep the edged log file at 1MB in size.

Summary

There are other ways to accomplish start-on-boot behavior and rotate log files. If you have other methods, please feel free to share them and/or comment on how these might be improved.

Thanks!

~Will Charlton

1 Like

SystemD

Another popular (maybe the most popular) process manager is systemd. To put ExoEdge under systemd control, copy the contents, below into a new file named edged.service.

NOTE: Edit the ExecStart and other directives as necessary.

[Unit]
Description=Edged
Documentation=https://pypi.org/project/exoedge/ https://community.exosite.com/c/exoedge
[Service]
ExecStart=/home/pi/phidgets/bin/edged -i /home/pi/phidgets/tst999.ini go
Restart=always
[Install]
WantedBy=multi-user.target

Run the following commands:

> sudo cp edged.service /etc/systemd/system/
> sudo systemctl daemon-reload
> sudo systemctl start edged