A simple plugin for any executable Swift package that provides the ability to manage it via systemd
.
To install systemd
as a SwiftPM plugin, first add the following line to your Package.swift file:
.package(url: "https://github.com/MihaelIsaev/SwiftSystemd.git", from:"1.0.0")
The purpose of systemd
is to run your app as a daemon and monitor it.
The first step is to generate the appropriate config file and save it.
swift run systemd install
It will prompt you with a few questions to generate and save the correct config file.
Or you could use parameters to predefine values
Parameter | Description |
---|---|
-c,--config | Type of configuration: release or debug |
-t,--target | Executable target name |
-u,--user | User under which the service will run |
swift run systemd install -c release -t App -u mike
swift run systemd uninstall
Deletes the systemd
configuration file and stops the service if it is active.
swift run systemd start
Starts your app using systemctl start
swift run systemd restart
Restarts your app using systemctl restart
swift run systemd stop
Stops your app if it is running via systemd
, using systemctl stop
.
swift run systemd enable
Enables the existing service configuration via systemctl enable
.
swift run systemd disable
Disables the existing service configuration via systemctl disable
.
swift run systemd kill
Sends kill signal to the running service via systemctl kill
.
swift run systemd status
Shows status of your app via systemctl status
.
swift run systemd daemon-reload
Reloads all systemd
services via systemctl daemon-reload
.
swift run systemd logs
Displays live logs of your app via journalctl
.
swift run systemd logs --limit 100
Displays the last 100
lines from your app's log via journalctl
Please feel free to contribute!