Skip to content

Instantly share code, notes, and snippets.

@kyberorg
Forked from funzoneq/simplehttp.service
Last active April 12, 2019 08:02
Show Gist options
  • Save kyberorg/a7a2a10600589ae538154ce7e5c10188 to your computer and use it in GitHub Desktop.
Save kyberorg/a7a2a10600589ae538154ce7e5c10188 to your computer and use it in GitHub Desktop.
A systemd file for a python SimpleHTTPServer aka healtcheck daemon
[Unit]
Description=Job that runs the python SimpleHTTPServer daemon at TCP port 80
Documentation=man:SimpleHTTPServer(1)
After=network-online.target
[Service]
Type=simple
WorkingDirectory=/srv/hellcheck
ExecStart=/usr/bin/python -m SimpleHTTPServer 80 &
ExecStop=/bin/kill `/bin/ps aux | /bin/grep SimpleHTTPServer | /bin/grep -v grep | /usr/bin/awk '{ print $2 }'`
[Install]
WantedBy=multi-user.target

Mkdir and index.html

mkdir /srv/hellcheck

vim /srv/hellcheck/index.html

<h1>It works!</h1>

Service

vim /etc/systemd/system/hellcheck.service

Detect service

systemctl daemon-reload

systemctl restart hellcheck.service

Logs

journalctl -u hellcheck.service

Enable at boot

systemctl enable hellcheck.service

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment