-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
61 lines (49 loc) · 1.42 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#!/usr/bin/python3
import os, sys, imp
# Configuration info.
madz_config = {
"user_config_env": "CRAFT_ENGINE_USER_CONFIG",
"log_to_stdout": True,
"logging_file": "./engine.log",
"plugin_directories" : ["./plugins/", "./executables/"],
"plugin_configs" : ["system_config.py"],
}
attached = False
def attach_madz():
"""Add Madz to your system path"""
global attached
if not attached:
os.chdir(os.path.split(os.path.realpath(__file__))[0])
sys.path.append(os.path.abspath("../massive-dangerzone/"))
attached = True
def start_daemon():
"""Start a Madz Server"""
attach_madz()
import madz.live_script as madz
daemon = madz.Daemon(**madz_config)
print("Configuring Server...")
daemon.configure()
print("Starting Server")
daemon.start()
def create_client():
attach_madz()
import madz.live_script as madz
return madz.Client(madz_config)
def send_kill():
import madz.live_script as madz
madz.kill()
def _usage():
print("Usage: main.py {daemon} | command {command_name} [-p {plugin_namespace}] [-l{log_level}]}")
exit(1)
if __name__ == '__main__':
if len(sys.argv) == 1:
_usage()
attach_madz()
if sys.argv[1] == "daemon":
start_daemon()
elif sys.argv[1] == "kill":
client = create_client()
client.kill()
else:
client = create_client()
client.run_raw(sys.argv)