Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Tree: 0957c7d9b4
Fetching contributors…

Cannot retrieve contributors at this time

executable file 67 lines (50 sloc) 1.623 kB
#!/usr/bin/env python
import signal
import sys
import os
from musik import initLogging
import musik.library.importer
import musik.web.application
# cleans up and safely stops the application
def cleanup(signum=None, frame=None):
global log, importThread, app
if type(signum) == type(None):
pass
else:
log.info(u'Signal %i caught, saving and exiting...', int(signum))
log.info(u'Stopping worker threads')
if importThread != None:
importThread.stop()
importThread.join(5)
if importThread.isAlive():
log.error(u'Failed to clean up importThread')
log.info(u'Stopping CherryPy Engine')
app.stop()
log.info(u'Clean up complete')
sys.exit(0)
# application entry - starts the database connection and dev server
if __name__ == '__main__':
global log, importThread, app
threads = []
# get logging set up
# confirm that logging directory exists
log_dir = os.path.join(os.getcwd(), "logs") # default logging location
if not os.path.isdir(log_dir):
try:
os.mkdir(log_dir)
except IOError:
print u"Could not create log directory %s" % log_dir
sys.exit(1)
log = initLogging(__name__)
# TODO: also register for CherryPy shutdown messages
log.info(u'Registering for shutdown signals')
for sig in [signal.SIGTERM, signal.SIGINT, signal.SIGHUP, signal.SIGQUIT]:
signal.signal(sig, cleanup)
log.info(u'Starting worker threads')
importThread = musik.library.importer.ImportThread()
importThread.start()
threads.append(importThread)
# this is a blocking call
log.info(u'Starting Web App')
app = musik.web.application.MusikWebApplication(log=log, threads=threads)
app.start()
Jump to Line
Something went wrong with that request. Please try again.