Example #1
0
# Writing the pidfile
pidFile = option('pidfile')
if pidFile:
	with open(pidFile, 'w') as f:
		f.write("%d\n" % os.getpid())

restart = False
preServer.stop()

try:
	server = getServer()
except ServerError, e:
	console('server', e.message)
	exit(1)

Cron.start()
WebSocket.start()

try:
	console('rorn', 'Listening for connections')
	try:
		server.serve_forever()
	except socket.error, e:
		if e.errno == errno.EBADF and (bricked() or '').startswith('Restart'):
			restart = True
		else:
			raise
except KeyboardInterrupt:
	sys.__stdout__.write("\n\n")
	console('main', 'Exiting at user request')
except (Exception, SystemExit), e: