Results 1 to 8 of 8

Thread: Can't get service to start on boot

  1. #1
    drhedberg NNTP User

    Default Can't get service to start on boot

    Mullvad VPN won't enable on boot.

    Code:
    sudo systemctl enable mullvad-daemon.service
    Code:
    sudo systemctl start mullvad-daemon.service
    VPN runs and connects successfully. But after reboot the application starts but hangs on "connecting to Mullvad system service."

    I then
    Code:
    sudo systemctl start mullvad-daemon.service
    and it connects and runs fine.

    I check in Yast under services-manager on a fresh boot and it is in fact set to start on boot but it is listed as "Inactive(Dead)" until I manually start it.

    What am I doing wrong? I thought using the enable flag sets it to start on boot so that one doesn't have to use the "start" flag every time on boot?

    Thanks

  2. #2
    Join Date
    Jun 2008
    Location
    San Diego, Ca, USA
    Posts
    11,306
    Blog Entries
    2

    Default Re: Can't get service to start on boot

    Quote Originally Posted by drhedberg View Post
    Mullvad VPN won't enable on boot.

    Code:
    sudo systemctl enable mullvad-daemon.service
    Code:
    sudo systemctl start mullvad-daemon.service
    VPN runs and connects successfully. But after reboot the application starts but hangs on "connecting to Mullvad system service."

    I then
    Code:
    sudo systemctl start mullvad-daemon.service
    and it connects and runs fine.

    I check in Yast under services-manager on a fresh boot and it is in fact set to start on boot but it is listed as "Inactive(Dead)" until I manually start it.

    What am I doing wrong? I thought using the enable flag sets it to start on boot so that one doesn't have to use the "start" flag every time on boot?

    Thanks
    Who provided you with the systemd Unit file? Multivad?
    My guess is that it doesn't have a line "Requires = network.service" or something like that, so you VPN attempts to start before your regular network connection is made.

    If you haven't done this before, run the following which will read your Unit file, include any possible relevant entries in the system log and most importantly at the moment the location of the Unit file
    Code:
    systemctl status mullvad-daemon.service
    Never edit a file directly in that location, instead copy your file to the following location with the following command, assuming that your Unit file is in the "system" and not "user" subdirectory of systemd
    Code:
    /etc/systemd/system/
    Now, edit your copy as you see fit.
    By copying the Unit file like this, your copy will take precedence over the original file, and if you ever want to return to the original (default) file, you simply delete your copy.

    TSU
    Beginner Wiki Quickstart - https://en.opensuse.org/User:Tsu2/Quickstart_Wiki
    Solved a problem recently? Create a wiki page for future personal reference!
    Learn something new?
    Attended a computing event?
    Post and Share!

  3. #3
    drhedberg NNTP User

    Default Re: Can't get service to start on boot

    This is starting to make more sense to me after reading your generous response.

    Code:
    systemctl status mullvad-daemon.service
    ● mullvad-daemon.service - Mullvad VPN daemon
    Loaded: loaded (/opt/Mullvad VPN/resources/mullvad-daemon.service; enabled; vendor preset: disabled)
    Active: inactive (dead)


    Here is the file output in /opt:

    HTML Code:
    # Systemd service unit file for the Mullvad VPN daemon
    
    [Unit]
    Description=Mullvad VPN daemon
    Wants=network.target
    After=network-online.target
    After=NetworkManager.service
    After=systemd-resolved.service
    StartLimitBurst=5
    StartLimitIntervalSec=20
    
    [Service]
    Restart=always
    RestartSec=1
    ExecStart=/opt/Mullvad\x20VPN/resources/mullvad-daemon -v --disable-stdout-timestamps
    
    [Install]
    WantedBy=multi-user.target
    I was able to find the exact same file in /etc/systemd/service

    So does this mean I need to edit the file in /opt and copy it to the /etc directory? If so, is there a line I should add and in what part of the file?

    Thanks for your help with this. I'm getting closer to understanding.

  4. #4
    Join Date
    Jun 2008
    Location
    San Diego, Ca, USA
    Posts
    11,306
    Blog Entries
    2

    Default Re: Can't get service to start on boot

    Quote Originally Posted by drhedberg View Post
    This is starting to make more sense to me after reading your generous response.

    Code:
    systemctl status mullvad-daemon.service
    ● mullvad-daemon.service - Mullvad VPN daemon
    Loaded: loaded (/opt/Mullvad VPN/resources/mullvad-daemon.service; enabled; vendor preset: disabled)
    Active: inactive (dead)


    Here is the file output in /opt:

    HTML Code:
    # Systemd service unit file for the Mullvad VPN daemon
    
    [Unit]
    Description=Mullvad VPN daemon
    Wants=network.target
    After=network-online.target
    After=NetworkManager.service
    After=systemd-resolved.service
    StartLimitBurst=5
    StartLimitIntervalSec=20
    
    [Service]
    Restart=always
    RestartSec=1
    ExecStart=/opt/Mullvad\x20VPN/resources/mullvad-daemon -v --disable-stdout-timestamps
    
    [Install]
    WantedBy=multi-user.target
    I was able to find the exact same file in /etc/systemd/service

    So does this mean I need to edit the file in /opt and copy it to the /etc directory? If so, is there a line I should add and in what part of the file?

    Thanks for your help with this. I'm getting closer to understanding.
    IMO the Unit file could be considered faulty... "Wants" might be sufficient most of the time but IMO should be "Requires" to ensure you don't try to set up the VPN until after networking is functional.

    Here is some discussion that further elaborates my point
    https://serverfault.com/questions/81...r-and-requires
    https://unix.stackexchange.com/quest...uires-vs-wants

    In fact, do what I describe and replace "Wants" with "Requires" and then reboot (There is a way to invoke changes to your Unit files, but in your case you're altering the boot flow, so why not just reboot and test right away).

    TSU
    Beginner Wiki Quickstart - https://en.opensuse.org/User:Tsu2/Quickstart_Wiki
    Solved a problem recently? Create a wiki page for future personal reference!
    Learn something new?
    Attended a computing event?
    Post and Share!

  5. #5
    Join Date
    Sep 2012
    Posts
    5,143

    Default Re: Can't get service to start on boot

    Quote Originally Posted by drhedberg View Post
    But after reboot the application starts but hangs on "connecting to Mullvad system service."
    It sounds like it starts before network is up.

    Quote Originally Posted by drhedberg View Post
    Code:
    # Systemd service unit file for the Mullvad VPN daemon
    
    [Unit]
    Description=Mullvad VPN daemon
    Wants=network.target
    After=network-online.target
    That alone is not enough, you also need some service that actually waits until network is online and orders itself before network-online.target. If you are using NetworkManager, this would be NetworkManager-wait-online.service.
    Code:
    After=NetworkManager.service
    That's not enough either, NetworkManager startup completes as soon as daemon is started whereas it can take quite a lot of time to actually activate connection.

  6. #6
    drhedberg NNTP User

    Default Re: Can't get service to start on boot

    Quote Originally Posted by tsu2 View Post
    IMO the Unit file could be considered faulty... "Wants" might be sufficient most of the time but IMO should be "Requires" to ensure you don't try to set up the VPN until after networking is functional.

    Here is some discussion that further elaborates my point
    https://serverfault.com/questions/81...r-and-requires
    https://unix.stackexchange.com/quest...uires-vs-wants

    In fact, do what I describe and replace "Wants" with "Requires" and then reboot (There is a way to invoke changes to your Unit files, but in your case you're altering the boot flow, so why not just reboot and test right away).

    TSU
    Thanks for the resources. This has become to complicated for me so I need to move on.

  7. #7
    drhedberg NNTP User

    Default Re: Can't get service to start on boot

    Quote Originally Posted by arvidjaar View Post
    It sounds like it starts before network is up.


    That alone is not enough, you also need some service that actually waits until network is online and orders itself before network-online.target. If you are using NetworkManager, this would be NetworkManager-wait-online.service.

    That's not enough either, NetworkManager startup completes as soon as daemon is started whereas it can take quite a lot of time to actually activate connection.
    Thanks for the information. This is all above my head so I need to move on.

  8. #8
    Join Date
    Jan 2014
    Location
    Erlangen
    Posts
    1,010

    Default Re: Can't get service to start on boot

    Quote Originally Posted by drhedberg View Post
    Mullvad VPN won't enable on boot.

    Code:
    sudo systemctl enable mullvad-daemon.service
    Code:
    sudo systemctl start mullvad-daemon.service
    VPN runs and connects successfully. But after reboot the application starts but hangs on "connecting to Mullvad system service."

    I then
    Code:
    sudo systemctl start mullvad-daemon.service
    and it connects and runs fine.

    I check in Yast under services-manager on a fresh boot and it is in fact set to start on boot but it is listed as "Inactive(Dead)" until I manually start it.

    What am I doing wrong? I thought using the enable flag sets it to start on boot so that one doesn't have to use the "start" flag every time on boot?

    Thanks
    There are two targets related to networking:

    Code:
    erlangen:~ # systemctl list-unit-files network*
    UNIT FILE             STATE  
    network.service       enabled
    network-online.target static 
    network-pre.target    static 
    network.target        static 
    
    4 unit files listed.
    erlangen:~ #

    Code:
    erlangen:~ # journalctl -b -u systemd-networkd* -o short-monotonic 
    -- Logs begin at Tue 2019-09-03 21:44:16 CEST, end at Thu 2019-09-05 19:01:33 CEST. --
    [    3.554512] erlangen systemd[1]: Starting Network Service...
    [    4.295335] erlangen systemd-networkd[691]: Enumeration completed
    [    4.295511] erlangen systemd[1]: Started Network Service.
    [    4.296281] erlangen systemd[1]: Starting Wait for Network to be Configured...
    [    8.945394] erlangen systemd-networkd[691]: eth0: Gained carrier
    [   10.914964] erlangen systemd-networkd[691]: eth0: Gained IPv6LL
    [   10.915733] erlangen systemd-networkd[691]: eth0: Configured
    [   10.918280] erlangen systemd[1]: Started Wait for Network to be Configured.
    erlangen:~ #
    On my machine fetchmail.service would start upon network.target being reached, which caused it to report some distracting errors. I told it to wait until network-online.target was reached by running 'systemctl edit fetchmail.service' and adding 2 lines:

    Code:
    erlangen:~ # systemctl cat fetchmail.service 
    # /usr/lib/systemd/system/fetchmail.service
    [Unit]
    Description=A remote-mail retrieval utility
    After=network.target
    
    [Service]
    EnvironmentFile=-/etc/sysconfig/fetchmail
    User=fetchmail
    ExecStart=/usr/lib/fetchmail-systemd-exec
    RestartSec=1
    
    [Install]
    WantedBy=multi-user.target
    
    # /etc/systemd/system/fetchmail.service.d/override.conf
    [Unit]
    After=network-online.target
    erlangen:~ #
    Now fetchmail.service waits until network-online.target is reached (links are configured)

    Code:
    erlangen:~ # journalctl -b -u fetchmail.service -o short-monotonic 
    -- Logs begin at Tue 2019-09-03 21:44:16 CEST, end at Thu 2019-09-05 19:12:09 CEST. --
    [   10.923745] erlangen systemd[1]: Started A remote-mail retrieval utility.
    [   10.938396] erlangen fetchmail[1141]: starting fetchmail 6.3.26 daemon
    erlangen:~ #
    AMD Athlon 4850e (2009), openSUSE 13.1, KDE 4, Intel i3-4130 (2014), i7-6700K (2016), i5-8250U (2018), openSUSE Tumbleweed, KDE Plasma 5

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •