def asyncGet(self): statusCode = 400 data = {"message": "unknown error"} try: # Check arguments if not requestsManager.checkArguments(self.request.arguments, ["k"]): raise exceptions.invalidArgumentsException() # Check ci key key = self.get_argument("k") if key is None or key != glob.conf.config["server"]["cikey"]: raise exceptions.invalidArgumentsException() log.info("Ci event triggered!!") systemHelper.scheduleShutdown( 5, False, "A new Bancho update is available and the server will be restarted in 5 seconds. Thank you for your patience." ) # Status code and message statusCode = 200 data["message"] = "ok" except exceptions.invalidArgumentsException: statusCode = 400 data["message"] = "invalid ci key" finally: # Add status code to data data["status"] = statusCode # Send response self.write(json.dumps(data)) self.set_status(statusCode)
def instantRestart(fro, chan, message): glob.streams.broadcast( "main", serverPackets.notification("We are restarting Bancho. Be right back!")) systemHelper.scheduleShutdown(0, True, delay=5) return False
def restartShutdown(restart): """Restart (if restart = True) or shutdown (if restart = False) pep.py safely""" msg = "We are performing some maintenance. Bancho will {} in 5 seconds. Thank you for your patience.".format( "restart" if restart else "shutdown") systemHelper.scheduleShutdown(5, restart, msg) return msg