(Last Updated: May 11, 2020)

Auto Start z-way-server



  • This could probably done in a script but short of it, this is the fairly simple process:

    from the SSH or terminal prompt of ubuntu run this:

    sudo nano /etc/systemd/system/z-way-server.service
    

    then paste the following:

    # /etc/systemd/system/z-way-server.service
    #       systemctl enable z-way-server
    #       systemctl start z-way-server
    #       journalctl -f
    [Unit]
     Description=z-way server
     Wants=network-online.target
     After=network-online.target
    
    [Service]
    Type=simple
    # User= Group=owntracks
    WorkingDirectory=/opt/z-way-server
    Environment='LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/z-way-server/libs'
    ExecStart=/opt/z-way-server/z-way-server
    Restart=always
    RestartSec=15
    StandardOutput=syslog
    StandardError=syslog
    SyslogIdentifier=z-way-server
    
    [Install]
    WantedBy=multi-user.target
    

    then

    sudo systemctl enable z-way-server
    

    z-way-server will start automatically at the next reboot.

    I probably should also post how to make it rotate logs... This will be another post.



  • Thank you, that works!

    But make the first line with a "sudo" else it won't work

    sudo nano /etc/systemd/system/z-way-server.service



  • You are correct. I missed that and corrected it. Thanks for reporting back!



  • Just wandering if a wait on network should be added.
    With a pi this is done using raspi-config, but any other Linux distribution doesn't have that.

    Maybe add?

    [Unit]
    Wants=network-online.target
    After=network-online.target
    


  • I did not need in my VM case but it can’t hurt and certainly can help other installations.
    Thanks for the input! It’s updated.


Log in to reply