notes on beaglebone 2: systemd
Mar. 12th, 2015 11:03 pm![[personal profile]](https://www.dreamwidth.org/img/silk/identity/user.png)
You want a program to start running every time the beaglebone boots.
Use systemd because it's there and it actually works okay.
In /lib/systemd/system/ make a file (programname).service
So for this example, blinker.service
It should look like this:
[Unit]
Description=blinker
ConditionPathExists=|/home/debian/programming/python
[Service]
ExecStart=/home/debian/programming/python/blinker.py
SyslogIdentifier=blinker
Restart=always
[Install]
WantedBy=multi-user.target
Then go to /etc/systemd/system/multi-user.target.wants and make a symlink to that file.
ln -s /lib/systemd/system/blinker.service /etc/systemd/system/multi-user.target.wants/blinker.service
The file itself, if it's python, must begin with #!/usr/bin/python (or wherever you have python installed) and be executable.
Then, systemctl --system daemon-reload
and systemctl start blinker.service
and your program should start immediately and also start every time you boot the beaglebone.
If your program is dependent on other services before it starts, you can add those under the [unit] group, like:
ConditionPathExists=|/home/debian/programming/python
After=network.target
That way it will wait until the network is up before running -- which, in the case of what I'm building, is nice, because it's streaming internet radio.
Use systemd because it's there and it actually works okay.
In /lib/systemd/system/ make a file (programname).service
So for this example, blinker.service
It should look like this:
[Unit]
Description=blinker
ConditionPathExists=|/home/debian/programming/python
[Service]
ExecStart=/home/debian/programming/python/blinker.py
SyslogIdentifier=blinker
Restart=always
[Install]
WantedBy=multi-user.target
Then go to /etc/systemd/system/multi-user.target.wants and make a symlink to that file.
ln -s /lib/systemd/system/blinker.service /etc/systemd/system/multi-user.target.wants/blinker.service
The file itself, if it's python, must begin with #!/usr/bin/python (or wherever you have python installed) and be executable.
Then, systemctl --system daemon-reload
and systemctl start blinker.service
and your program should start immediately and also start every time you boot the beaglebone.
If your program is dependent on other services before it starts, you can add those under the [unit] group, like:
ConditionPathExists=|/home/debian/programming/python
After=network.target
That way it will wait until the network is up before running -- which, in the case of what I'm building, is nice, because it's streaming internet radio.