Last active
May 30, 2019 09:44
-
-
Save syntaqx/0625ee4209319c383a5170565227936d to your computer and use it in GitHub Desktop.
Interfacing with systemd for a basic binary service.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Unit] | |
Description=A dead simple REST API for Docker Swarm | |
Documentation=https://github.com/syntaqx/swarm-api | |
After=network.target | |
[Service] | |
Type=simple | |
Restart=always | |
RestartSec=5s | |
Environment=PORT=8080 | |
ExecStartPre=/bin/bash -c "/bin/systemctl set-environment HOST=$(curl -sfL http://169.254.169.254/metadata/v1/interfaces/private/0/ipv4/address)" | |
ExecStart=/bin/swarm-api --host "$HOST" | |
[Install] | |
WantedBy=multi-user.target |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
curl -sfL https://install.goreleaser.com/github.com/syntaqx/swarm-api.sh | sh -s -- -b /bin | |
systemctl enable swarm-api.service | |
systemctl start swarm-api.service |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# log messages | |
journalctl -u swarm-api.service | |
# status listing | |
systemctl -l status swarm-api |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment