|
|
@ -12,7 +12,10 @@ import os
|
|
|
|
import time
|
|
|
|
import time
|
|
|
|
|
|
|
|
|
|
|
|
def mgmt():
|
|
|
|
def mgmt():
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
Primary management function. Main loop that starts and runs all bureaus.
|
|
|
|
|
|
|
|
Some day this will do nice supervisory things like restart crashed buros.
|
|
|
|
|
|
|
|
"""
|
|
|
|
basepath = os.path.expanduser("~/.screenless")
|
|
|
|
basepath = os.path.expanduser("~/.screenless")
|
|
|
|
if not os.path.exists(basepath):
|
|
|
|
if not os.path.exists(basepath):
|
|
|
|
os.mkdir(basepath)
|
|
|
|
os.mkdir(basepath)
|
|
|
@ -21,11 +24,13 @@ def mgmt():
|
|
|
|
config = configparser.ConfigParser()
|
|
|
|
config = configparser.ConfigParser()
|
|
|
|
procs = {}
|
|
|
|
procs = {}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
config.read("mgmt.ini")
|
|
|
|
config.read("mgmt.ini")
|
|
|
|
org_chart = config["mgmt"]["bureaus"].split()
|
|
|
|
org_chart = config["mgmt"]["bureaus"].split()
|
|
|
|
except KeyError:
|
|
|
|
except KeyError:
|
|
|
|
config["mgmt"] = {"bureaus": "ihr typing"}
|
|
|
|
config["mgmt"] = {"bureaus":
|
|
|
|
|
|
|
|
"ihr typing publicrelations photography jokes"}
|
|
|
|
with open("mgmt.ini", "w") as configfile:
|
|
|
|
with open("mgmt.ini", "w") as configfile:
|
|
|
|
config.write(configfile)
|
|
|
|
config.write(configfile)
|
|
|
|
print("created new mgmt.ini config file. please modify this to suit.")
|
|
|
|
print("created new mgmt.ini config file. please modify this to suit.")
|
|
|
@ -35,9 +40,9 @@ def mgmt():
|
|
|
|
|
|
|
|
|
|
|
|
for buro in org_chart:
|
|
|
|
for buro in org_chart:
|
|
|
|
lib = importlib.import_module("bureau." + buro)
|
|
|
|
lib = importlib.import_module("bureau." + buro)
|
|
|
|
# run lib.main() in a separate process
|
|
|
|
|
|
|
|
proc = multiprocessing.Process(target=lib.main)
|
|
|
|
proc = multiprocessing.Process(target=lib.main)
|
|
|
|
procs[buro] = proc.start()
|
|
|
|
procs[buro] = proc
|
|
|
|
|
|
|
|
proc.start()
|
|
|
|
|
|
|
|
|
|
|
|
while True:
|
|
|
|
while True:
|
|
|
|
for buro in org_chart:
|
|
|
|
for buro in org_chart:
|
|
|
@ -45,8 +50,6 @@ def mgmt():
|
|
|
|
if not proc.is_alive():
|
|
|
|
if not proc.is_alive():
|
|
|
|
print("bureau", buro, "has crashed! Call the consultants!")
|
|
|
|
print("bureau", buro, "has crashed! Call the consultants!")
|
|
|
|
#TODO this should probably restart in some sensible way
|
|
|
|
#TODO this should probably restart in some sensible way
|
|
|
|
else:
|
|
|
|
|
|
|
|
print("bureau", buro, "still running...")
|
|
|
|
|
|
|
|
time.sleep(1)
|
|
|
|
time.sleep(1)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|