Skip to content

Running liwan as a Service

liwan can run as a service so it starts automatically when your server boots. This page shows examples for systemd and OpenRC.

  1. Creating the service
    Create /etc/systemd/system/liwan.service:

    /etc/systemd/system/liwan.service
    [Unit]
    Description=liwan web analytics
    After=network.target
    [Service]
    # Replace `yourusername` with your username
    ExecStart=/home/yourusername/.local/bin/liwan
    Restart=on-failure
    User=yourusername
    [Install]
    WantedBy=multi-user.target

    Replace yourusername and adjust the paths to match your setup. To generate a configuration file, you can run liwan generate-config -o ~/.config/liwan/liwan.config.toml.

  2. Starting the service
    After creating the service file, reload the systemd daemon and start the service:

    Terminal window
    # Reload the systemd daemon
    sudo systemctl daemon-reload
    # Enable the service to start automatically on boot
    sudo systemctl enable liwan
    # Start the service
    sudo systemctl start liwan
  3. Checking the status
    You can now check the status of the service using systemctl status liwan and view the logs using journalctl -u liwan. The logs contain the initial setup URL.