mirror of
https://github.com/krateng/maloja.git
synced 2023-08-10 21:12:55 +03:00
![Brian Pepple](/assets/img/avatar_default.png)
* Merge isinstance calls * Inline variable that is immediately returned * Replace set() with comprehension * Replace assignment with augmented assignment * Remove unnecessary else after guard condition * Convert for loop into list comprehension * Replace unused for index with underscore * Merge nested if conditions * Convert for loop into list comprehension * Convert for loop into set comprehension * Remove unnecessary else after guard condition * Replace if statements with if expressions * Simplify sequence comparison * Replace multiple comparisons with in operator * Merge isinstance calls * Merge nested if conditions * Add guard clause * Merge duplicate blocks in conditional * Replace unneeded comprehension with generator * Inline variable that is immediately returned * Remove unused imports * Replace unneeded comprehension with generator * Remove unused imports * Remove unused import * Inline variable that is immediately returned * Swap if/else branches and remove unnecessary else * Use str.join() instead of for loop * Multiple refactors - Remove redundant pass statement - Hoist repeated code outside conditional statement - Swap if/else to remove empty if body * Inline variable that is immediately returned * Simplify generator expression * Replace if statement with if expression * Multiple refactoring - Replace range(0, x) with range(x) - Swap if/else branches - Remove unnecessary else after guard condition * Use str.join() instead of for loop * Hoist repeated code outside conditional statement * Use str.join() instead of for loop * Inline variables that are immediately returned * Merge dictionary assignment with declaration * Use items() to directly unpack dictionary values * Extract dup code from methods into a new one
41 lines
815 B
Python
41 lines
815 B
Python
#!/usr/bin/env python3
|
|
import os
|
|
|
|
import subprocess
|
|
import setproctitle
|
|
import signal
|
|
from doreah.logging import log
|
|
from doreah.settings import get_settings
|
|
|
|
from .control import getInstance
|
|
|
|
|
|
setproctitle.setproctitle("maloja_supervisor")
|
|
|
|
def update():
|
|
log("Updating...",module="supervisor")
|
|
try:
|
|
os.system("pip3 install maloja --upgrade --no-cache-dir")
|
|
except:
|
|
log("Could not update.",module="supervisor")
|
|
|
|
def start():
|
|
try:
|
|
return subprocess.Popen(
|
|
["python3", "-m", "maloja.server"],
|
|
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")
|
|
if get_settings("UPDATE_AFTER_CRASH"):
|
|
update()
|
|
process = start()
|
|
|
|
process.wait()
|