Skip to content

Ship systemd service + make install + fix updater restart #16

@butterson1

Description

@butterson1

Problem

After self-update, the app exits cleanly (code 0) expecting to be restarted — but there is no standard service file shipped, and users running it manually or with Restart=on-failure will find it stays dead after update.

There is also no make install target, so deployment is ad-hoc.

Proposal

1. Ship a systemd service file

Add deploy/opensnitch-web.service:

[Unit]
Description=OpenSnitch Web UI
After=network-online.target
Wants=network-online.target

[Service]
Type=simple
WorkingDirectory=/opt/opensnitch-web
ExecStart=/opt/opensnitch-web/opensnitch-web -config /opt/opensnitch-web/config.yaml
Restart=always
RestartSec=3

[Install]
WantedBy=multi-user.target

2. Add make install / make uninstall

PREFIX ?= /opt/opensnitch-web

install: build
	install -Dm755 bin/opensnitch-web $(PREFIX)/opensnitch-web
	test -f $(PREFIX)/config.yaml || install -Dm644 config.yaml.example $(PREFIX)/config.yaml
	install -Dm644 deploy/opensnitch-web.service /etc/systemd/system/opensnitch-web.service
	systemctl daemon-reload
	@echo "Run: systemctl enable --now opensnitch-web"

uninstall:
	systemctl disable --now opensnitch-web || true
	rm -f /etc/systemd/system/opensnitch-web.service
	systemctl daemon-reload

3. Fix updater restart logic

Current behavior: sends SIGTERM to self and hopes something restarts it.

Better options (pick one):

  • Option A: Exit with a specific code (e.g. 42) and add RestartForceExitStatus=42 to the service file — systemd always restarts on that code regardless of Restart= policy
  • Option B: After replacing binary, call systemctl restart opensnitch-web instead of self-terminating
  • Option C: Keep current SIGTERM approach but document that Restart=always is required (simplest)

Option A is the cleanest — it explicitly communicates "I updated, restart me" to the service manager.

4. Update README

Add install section:

make build
sudo make install
sudo systemctl enable --now opensnitch-web

Context

Discovered when self-update from settings page successfully downloaded and replaced the binary, then exited cleanly — but systemd did not restart the service because Restart=on-failure ignores exit code 0.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions