-
Notifications
You must be signed in to change notification settings - Fork 1
/
start.py
executable file
·34 lines (34 loc) · 998 Bytes
/
start.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
#!/usr/bin/python3
# coding: utf-8
import os
import sys
import time
c = 0
selfn = sys.argv[0]
dirn = os.path.dirname(selfn)
server = os.path.join(dirn, 'server.py')
if len(sys.argv) > 1:
match sys.argv[1]:
case 'screen':
st = os.system(f'cd {dirn} && screen -dmS sleepy {sys.argv[0]}')
if st == 0:
print(f'Started screen: cd {dirn} && screen -dmS sleepy {sys.argv[0]}')
while True:
time.sleep(114514)
#exit(0)
else:
print(f'Start screen failed: cd {dirn} && screen -dmS sleepy {sys.argv[0]}')
exit(1)
case _:
print('Invaild arg.')
exit(1)
print(f'Server path: {server}')
while True:
c += 1
print(f'Starting server #{c}')
if os.name == 'nt':
r = os.system(f'python {server}')
else:
r = os.system(f'python3 {server}')
print(f'#{c} exited with code {r}\nwaiting 5s')
time.sleep(5)