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?

Étienne
  • 123
  • 9
RQDQ
  • 153
  • 1
  • 1
  • 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. – RQDQ May 04 '18 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.](https://www.freedesktop.org/software/systemd/man/systemd.unit.html#Unit%20File%20Load%20Path) 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. – ErikF May 04 '18 at 17:55
  • @ErikF - I think in this case, because I'm building the distribution using YOCTO, I _am_ the distribution. – RQDQ May 04 '18 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. – ErikF May 04 '18 at 18:51
  • @ErikF - YOCTO is great - once you get past the really really steep learning curve. :-) – RQDQ May 04 '18 at 19:34
  • Complementing the EDIT part in the question: From Yocto mega manual v2.4: > By default, the service is enabled to automatically start at boot > time. The default setting is in the systemd class as follows: > > SYSTEMD_AUTO_ENABLE ??= "enable" – fabatera Jun 26 '19 at 09:49

3 Answers3

7

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"
cprewit
  • 71
  • 1
  • 2
  • 2
    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 https://www.yoctoproject.org/docs/current/mega-manual/mega-manual.html#var-SYSTEMD_AUTO_ENABLE – Étienne Oct 11 '19 at 11:42
4

You need to enable it a boot time:

systemctl enable boondocks-agent

Bigon
  • 2,062
  • 16
  • 19
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"
Michael
  • 113
  • 5