Why isn't my systemd service automatically starting?

8,516

Solution 1

You need to enable it a boot time:

systemctl enable boondocks-agent

Solution 2

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"
Share:
8,516

Related videos on Youtube

RQDQ
Author by

RQDQ

Updated on September 18, 2022

Comments

  • RQDQ
    RQDQ over 1 year

    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?

    Edit

    In YOCTO, the equivalent to calling systemctl enable is:

    SYSTEMD_SERVICE_${PN} = " \
        boondocks-agent.service
        "
    
    • RQDQ
      RQDQ about 6 years
      @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
      RQDQ about 6 years
      @ErikF - I think in this case, because I'm building the distribution using YOCTO, I am the distribution.
    • ErikF
      ErikF about 6 years
      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.
    • RQDQ
      RQDQ about 6 years
      @ErikF - YOCTO is great - once you get past the really really steep learning curve. :-)
    • fabatera
      fabatera almost 5 years
      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"
  • nTOXIC
    nTOXIC over 4 years
    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/…