1
0
mirror of https://github.com/krateng/maloja.git synced 2023-08-10 21:12:55 +03:00

Janky self-restarter

This commit is contained in:
Krateng
2019-02-16 20:10:12 +01:00
parent 28f85300fe
commit 15a423060c
4 changed files with 42 additions and 7 deletions

View File

@@ -12,6 +12,7 @@ from urllib.error import *
import sys
import signal
import os
import restarter
MAIN_PORT = 42010
@@ -67,6 +68,12 @@ def database_post(pth):
def shutdown():
graceful_exit()
@webserver.route("/restart")
def restart():
urllib.request.urlopen("http://[::1]:" + str(DATABASE_PORT) + "/sync")
restarter.restart()
os._exit(42)
def graceful_exit(sig=None,frame=None):
urllib.request.urlopen("http://[::1]:" + str(DATABASE_PORT) + "/sync")
log("Server shutting down...")