30 lines
815 B
Python
30 lines
815 B
Python
#!/usr/bin/env python
|
|
|
|
import sys
|
|
import time
|
|
from daemon import Daemon
|
|
import rider_location_cache
|
|
|
|
class RiderLocationDaemon(Daemon):
|
|
def run(self):
|
|
rider_location = rider_location_cache.RiderLocationCache()
|
|
rider_location.run()
|
|
|
|
if __name__ == "__main__":
|
|
daemon = RiderLocationDaemon('/tmp/rider_location_daemon.pid')
|
|
if len(sys.argv) == 2:
|
|
if 'start' == sys.argv[1]:
|
|
daemon.start()
|
|
elif 'stop' == sys.argv[1]:
|
|
daemon.stop()
|
|
elif 'restart' == sys.argv[1]:
|
|
daemon.restart()
|
|
elif 'foreground' == sys.argv[1]:
|
|
daemon.run()
|
|
else:
|
|
print "Unknown command"
|
|
sys.exit(2)
|
|
sys.exit(0)
|
|
else:
|
|
print "usage: %s start|stop|restart" % sys.argv[0]
|
|
sys.exit(2)
|