mirror of
https://github.com/krateng/maloja.git
synced 2023-08-10 21:12:55 +03:00
Moved supervisor to __main__
This commit is contained in:
parent
87f1250629
commit
bceb0db09a
@ -7,6 +7,7 @@ from ipaddress import ip_address
|
|||||||
|
|
||||||
from doreah.control import mainfunction
|
from doreah.control import mainfunction
|
||||||
from doreah.io import col
|
from doreah.io import col
|
||||||
|
from doreah.logging import log
|
||||||
|
|
||||||
from . import __pkginfo__ as pkginfo
|
from . import __pkginfo__ as pkginfo
|
||||||
from . import globalconf
|
from . import globalconf
|
||||||
@ -50,7 +51,7 @@ def start():
|
|||||||
setup()
|
setup()
|
||||||
try:
|
try:
|
||||||
#p = subprocess.Popen(["python3","-m","maloja.server"],stdout=subprocess.DEVNULL,stderr=subprocess.DEVNULL)
|
#p = subprocess.Popen(["python3","-m","maloja.server"],stdout=subprocess.DEVNULL,stderr=subprocess.DEVNULL)
|
||||||
sp = subprocess.Popen(["python3","-m","maloja.proccontrol.supervisor"],stdout=subprocess.DEVNULL,stderr=subprocess.DEVNULL)
|
sp = subprocess.Popen(["python3","-m","maloja","supervisor"],stdout=subprocess.DEVNULL,stderr=subprocess.DEVNULL)
|
||||||
print(col["green"]("Maloja started!"))
|
print(col["green"]("Maloja started!"))
|
||||||
|
|
||||||
port = globalconf.malojaconfig["PORT"]
|
port = globalconf.malojaconfig["PORT"]
|
||||||
@ -93,6 +94,24 @@ def run_server():
|
|||||||
from . import server
|
from . import server
|
||||||
server.run_server()
|
server.run_server()
|
||||||
|
|
||||||
|
def run_supervisor():
|
||||||
|
setproctitle("maloja_supervisor")
|
||||||
|
while True:
|
||||||
|
log("Maloja is not running, starting...",module="supervisor")
|
||||||
|
try:
|
||||||
|
process = subprocess.Popen(
|
||||||
|
["python3", "-m", "maloja","run"],
|
||||||
|
stdout=subprocess.DEVNULL,
|
||||||
|
stderr=subprocess.DEVNULL,
|
||||||
|
)
|
||||||
|
except Exception as e:
|
||||||
|
log("Error starting Maloja: " + str(e),module="supervisor")
|
||||||
|
else:
|
||||||
|
try:
|
||||||
|
process.wait()
|
||||||
|
except Exception as e:
|
||||||
|
log("Maloja crashed: " + str(e),module="supervisor")
|
||||||
|
|
||||||
def debug():
|
def debug():
|
||||||
os.environ["MALOJA_DEV_MODE"] = 'true'
|
os.environ["MALOJA_DEV_MODE"] = 'true'
|
||||||
globalconf.malojaconfig.load_environment()
|
globalconf.malojaconfig.load_environment()
|
||||||
@ -117,6 +136,7 @@ def main(*args,**kwargs):
|
|||||||
"restart":restart,
|
"restart":restart,
|
||||||
"stop":stop,
|
"stop":stop,
|
||||||
"run":run_server,
|
"run":run_server,
|
||||||
|
"supervisor":run_supervisor,
|
||||||
"debug":debug,
|
"debug":debug,
|
||||||
"setup":onlysetup,
|
"setup":onlysetup,
|
||||||
# admin scripts
|
# admin scripts
|
||||||
|
@ -1,33 +0,0 @@
|
|||||||
#!/usr/bin/env python3
|
|
||||||
import os
|
|
||||||
|
|
||||||
from ..globalconf import malojaconfig
|
|
||||||
|
|
||||||
import subprocess
|
|
||||||
import setproctitle
|
|
||||||
import signal
|
|
||||||
from doreah.logging import log
|
|
||||||
|
|
||||||
|
|
||||||
from .control import getInstance
|
|
||||||
|
|
||||||
|
|
||||||
setproctitle.setproctitle("maloja_supervisor")
|
|
||||||
|
|
||||||
def start():
|
|
||||||
try:
|
|
||||||
return subprocess.Popen(
|
|
||||||
["python3", "-m", "maloja","run"],
|
|
||||||
stdout=subprocess.DEVNULL,
|
|
||||||
stderr=subprocess.DEVNULL,
|
|
||||||
)
|
|
||||||
except e:
|
|
||||||
log("Error starting Maloja: " + str(e),module="supervisor")
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
while True:
|
|
||||||
log("Maloja is not running, starting...",module="supervisor")
|
|
||||||
process = start()
|
|
||||||
|
|
||||||
process.wait()
|
|
Loading…
Reference in New Issue
Block a user