5

Here is my boondocks-agent.service file. I have installed it in /lib/systemd/system:

[Unit]
Description=Boondocks agent
Requires=\
    balena.service 
After=\
    balena.service 

[Service]
Type=simple
Restart=always
RestartSec=10s
WatchdogSec=60
EnvironmentFile=/etc/boondocks-agent/agent.conf
EnvironmentFile=-/tmp/boondocks-agent.conf
ExecStartPre=-/usr/bin/stop-boondocks-agent
ExecStart=/usr/bin/healthdog --healthcheck=/usr/lib/boondocks-agent/boondocks-agent-healthcheck  /usr/bin/start-boondocks-agent
ExecStop=-/usr/bin/stop-boondocks-agent

[Install]
WantedBy=multi-user.target

It doesn't appear to start up when I boot the system. After a clean boot, this is what I see for status:

systemctl status boondocks-agent
boondocks-agent.service - Boondocks agent
   Loaded: loaded (/lib/systemd/system/boondocks-agent.service; disabled; vendor preset: enabled)
   Active: inactive (dead)

What do I have to do to make this start up automatically on boot?

6
  • @UlrichSchwarz - apologies - the actual service file has the absolute path. The original question has the template I use to generate the file in a YOCTO build. I'll edit. Commented May 4, 2018 at 12:54
  • If this is a user-supplied unit, you really want to put it in /etc/systemd/system: the /lib/systemd/system directory is for the distribution's use. Although installers are good about not messing with foreign files, it's a risk that you don't have to take! Also, your /etc/systemd/ files will override anything in /lib/systemd/, preventing potential issues in the future. Commented May 4, 2018 at 17:55
  • @ErikF - I think in this case, because I'm building the distribution using YOCTO, I am the distribution. Commented May 4, 2018 at 18:24
  • Sorry, I forgot about that. I've gotten lazy and let my distros do all the grunt work for me! :-) I should really give it a shot; YOCTO looks really interesting. Commented May 4, 2018 at 18:51
  • @ErikF - YOCTO is great - once you get past the really really steep learning curve. :-) Commented May 4, 2018 at 19:34

4 Answers 4

8

You say,

In YOCTO, the equivalent to calling systemctl enable is:

   SYSTEMD_SERVICE_${PN} = " \
       boondocks-agent.service
       "

I think this is the equivalent to installing the service.  To have the service default to enabled you would want to add:

SYSTEMD_AUTO_ENABLE_${PN} = "enable"
1
  • 3
    SYSTEMD_AUTO_ENABLE is per-default true, if the recipe inherits the systemd class. Therefore it should not be required to set it explicitely to true. See yoctoproject.org/docs/current/mega-manual/… Commented Oct 11, 2019 at 11:42
4

You need to enable it a boot time:

systemctl enable boondocks-agent

2

I had the same issue recently when working on a Yocto project. I had well specified in my Yocto recipe the following lines:

SYSTEMD_SERVICE:${PN} = "test.service"
SYSTEMD_AUTO_ENABLE:${PN} = "enable"

But, these were not effective until I realized that I had to make my recipe inheriting explicitly from systemd. This was done by adding the following line in my recipe

inherit systemd
0

I was having the same issue. I added a service and expected a timer to be start on boot. My timer was never started, but I could start it manually and have it run forever as expected. To get my Yocto project to create and start the timer I add to add

SYSTEMD_SERVICE_${PN} = " logrotate.service logrotate.timer"

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.