Skip to content

Instantly share code, notes, and snippets.

@mabnhdev
Created April 6, 2017 17:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mabnhdev/17a8cb7bdc4df947a1c24d42c32b1daf to your computer and use it in GitHub Desktop.
Save mabnhdev/17a8cb7bdc4df947a1c24d42c32b1daf to your computer and use it in GitHub Desktop.
Python notify daemon in snappy.
snapcraft.yaml:
name: test
version: '0.1'
summary: Test snappy daemonization
description: |
This is my-snap's description. You have a paragraph or two to tell the
most important story about your snap. Keep it under 100 words though,
we live in tweetspace and your description wants to look good in the snap
store.
grade: devel
confinement: devmode
apps:
test-daemon:
command: usr/bin/test-daemon
daemon: notify
parts:
tests:
plugin: dump
stage-packages:
- python-daemon
- python-systemd
source: src/tests
src/tests/usr/bin/test-daemon:
#!/usr/bin/env python
import daemon
import syslog
import time
from systemd.daemon import notify
def main():
notify('READY=1')
id = 0
while True:
id = id + 1
syslog.syslog(syslog.LOG_INFO, 'id={} hello {}!!!!'.format(id, 'world'))
time.sleep(60)
with daemon.DaemonContext():
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment