service.py 788 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. #!/usr/bin/env python2
  2. # -*- coding: utf-8 -*-
  3. from comar.service import *
  4. import os
  5. serviceType = "server"
  6. serviceDesc = _({"en": "Tox DHT bootstrap daemon"})
  7. serviceDefault = "off"
  8. CFGFILE = "/etc/tox-bootstrapd.conf"
  9. PIDDIR = "/var/run/tox-bootstrapd"
  10. PIDFILE = "%s/tox-bootstrapd.pid" % PIDDIR
  11. @synchronized
  12. def start():
  13. if not os.path.exists(PIDDIR):
  14. try:
  15. os.makedirs(PIDDIR)
  16. except:
  17. pass
  18. startService(command="/usr/bin/tox-bootstrapd",
  19. args="--config %s" % CFGFILE,
  20. donotify=True)
  21. @synchronized
  22. def stop():
  23. stopService(pidfile=PIDFILE,
  24. donotify=True)
  25. try:
  26. os.unlink(PIDFILE)
  27. except:
  28. pass
  29. def status():
  30. return isServiceRunning(pidfile=PIDFILE)