service.py 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. from comar.service import *
  2. import os
  3. serviceType = "local"
  4. serviceConf = "irqbalance"
  5. serviceDefault = "conditional"
  6. serviceDesc = _({"en": "Irqbalance Daemon",
  7. "tr": "Irqbalance Servisi"})
  8. @synchronized
  9. def start():
  10. args = ""
  11. oneshot = config.get("ONESHOT")
  12. affinity = config.get("IRQ_AFFINITY_MASK")
  13. if oneshot == "yes" and os.path.exists("/run/irqbalance.pid"):
  14. return
  15. if oneshot == "yes":
  16. args += ("--oneshot -f")
  17. if affinity:
  18. os.environ["IRQBALANCE_BANNED_CPUS"] = affinity
  19. startService(command="/usr/sbin/irqbalance",
  20. args=args, donotify=True)
  21. os.system("pidof -o %PPID /usr/sbin/irqbalance > /run/irqbalance.pid")
  22. @synchronized
  23. def stop():
  24. stopService(command="/usr/sbin/irqbalance",
  25. pidfile="/run/irqbalance.pid",
  26. donotify=True)
  27. try:
  28. os.unlink("/var/lock/subsys/irqbalance")
  29. except:
  30. pass
  31. def ready():
  32. status = is_on()
  33. if status == "on" or (status == "conditional" and os.path.exists("/sys/devices/system/cpu/cpu1")):
  34. start()
  35. def status():
  36. return isServiceRunning("/run/irqbalance.pid")