What is wrong with my systemd service

10,186

I finally managed to find out what was wrong. Systemd needs all Env Variables explicitly mentioned. However it looks like I had loads of troubles reloading systemd services. This is what i've ended up doing. the service needs to be stoped, the .service file moved to a location systemd does not read, after that reload systemd with systemctl daemon-reload and wait until systemctl status $SERVICE claims there is no such service. (Systemd might still reread the cache if status claims anything else) After that add the .service file again to the appropriate location and voila it finaly worked.

Share:
10,186
Toasterson
Author by

Toasterson

Updated on June 25, 2022

Comments

  • Toasterson
    Toasterson almost 2 years

    I have written a golang RestAPI based on labstack/echo and vuejs and have a working version compiled and everything runs nicely when I start it. So far so good.

    However when trying to integrate it with systemd to start the process at boot I am stuck. I have a service file.

    [Unit]
    Description=Server Software Manager
    After=network.target
    
    [Service]
    Type=simple
    ExecStart=/var/gameserver/steam/sman
    KillMode=process
    User=steam
    Group=steam
    Restart=on-failure
    SuccessExitStatus=2
    
    [Install]
    WantedBy=multi-user.target
    Alias=sman.service
    

    But everytime I want to start the service I get the following error.

    Feb 25 14:17:49 <SERVERNAME> systemd[1]: Stopped Server Software Manager.
    Feb 25 14:17:49 <SERVERNAME> systemd[1]: Started Server Software Manager.
    Feb 25 14:17:49 <SERVERNAME> systemd[1]: sman.service: Main process exited, code=exited, status=2/INVALIDARGUMENT
    Feb 25 14:17:49 <SERVERNAME> systemd[1]: sman.service: Unit entered failed state.
    Feb 25 14:17:49 <SERVERNAME> systemd[1]: sman.service: Failed with result 'exit-code'.
    Feb 25 14:17:50 <SERVERNAME> systemd[1]: sman.service: Service hold-off time over, scheduling restart.
    Feb 25 14:17:50 <SERVERNAME> systemd[1]: Stopped Server Software Manager.
    Feb 25 14:17:50 <SERVERNAME> systemd[1]: sman.service: Start request repeated too quickly.
    Feb 25 14:17:50 <SERVERNAME> systemd[1]: Failed to start Server Software Manager.
    Feb 25 14:19:59 <SERVERNAME> systemd[1]: Started Server Software Manager.
    

    According to google that error is when the Service exits with error code but when I run the Service manually as the steam user it does not do that.

    My assumption is that something is wrong with that unit file but I don't know what. And Systemd-analyze has also not complained. I am completely lost and thankful for any leads you might have help debug this.

    The output of jounarlctl -xfe -u sman:

    Feb 26 14:18:23 <SERVERNAME> systemd[1]: Started Server Software Manager.
    -- Subject: Unit sman.service has finished start-up
    -- Defined-By: systemd
    -- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
    -- 
    -- Unit sman.service has finished starting up.
    -- 
    -- The start-up result is done.
    

    Notes: OS: Ubuntu 16.04 LTS