-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathrun-server
executable file
·57 lines (45 loc) · 1.15 KB
/
run-server
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
#!/usr/bin/env python3
import subprocess
import json
import sys
import os
import subprocess
import atexit
import argparse
def _cleanup():
try:
_processor_proc.terminate()
except NameError:
pass
atexit.register(_cleanup)
def _error(msg):
sys.stderr.write('{}\n'.format(msg))
sys.exit(1)
cl_parser = argparse.ArgumentParser(description='Run Node server')
cl_parser.add_argument(
'--debug', '-d', help='Debug through node-inspector', action='store_true',
default=False,
)
args = cl_parser.parse_args()
try:
with open('settings.json', 'rt') as f:
settings = json.load(f)
except IOError:
sys.exit('settings.json doesn\'t exist')
for k, v in settings.items():
os.environ[k] = v
if not args.debug:
node_command = ['./node_modules/.bin/babel-node', '.', ]
else:
node_command = [
'./node_modules/.bin/babel-node', '--inspect', '--debug-brk', '.',
]
_processor_proc = subprocess.Popen(
['./services/project-processor/project-processor.py', ]
)
try:
subprocess.check_call(node_command)
except subprocess.CalledProcessError:
_error('Node failed')
except KeyboardInterrupt:
sys.exit(0)