1
0
Fork 0
trespassed/software/main.py

31 lines
933 B
Python
Raw Normal View History

2016-12-21 12:44:40 -05:00
from twisted.application.service import Service, Application
2017-01-11 12:08:12 -05:00
from twisted.internet import reactor, defer
2016-12-21 12:44:40 -05:00
2017-01-11 12:08:12 -05:00
from trespassed.game import game_init
2016-12-21 12:44:40 -05:00
from trespassed.serial import SerialService, watchdog_service
from trespassed.email import email_routine
2017-01-11 12:08:12 -05:00
from trespassed.status import status_service
from trespassed.web import WebService
2016-12-21 12:44:40 -05:00
2017-01-11 12:08:12 -05:00
reactor.callLater(5, email_routine, "Trespassed Service Restarted","")
2016-12-21 12:44:40 -05:00
application = Application("Trespassed")
2017-01-11 12:08:12 -05:00
2016-12-21 12:44:40 -05:00
serial_service = SerialService()
serial_service.setServiceParent(application)
2017-01-11 12:08:12 -05:00
web_service = WebService("tcp:8000")
web_service.setServiceParent(application)
watchdog_service.setServiceParent(application)
status_service.setServiceParent(application)
def cleanup():
from trespassed.media import MEDIA_CHANNELS
2017-01-11 12:08:12 -05:00
if MEDIA_CHANNELS.music is not None:
MEDIA_CHANNELS.music.stop()
reactor.addSystemEventTrigger('before', 'shutdown', cleanup)
2017-01-11 12:08:12 -05:00
reactor.callLater(2, game_init)