-
Notifications
You must be signed in to change notification settings - Fork 0
/
ark_restart.py
48 lines (42 loc) · 1.66 KB
/
ark_restart.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
import time
from random import choice
from ark_manager import *
from debug import get_logger
log = get_logger("ark_other_scripts")
from locks import Lock
import argparse
parser = argparse.ArgumentParser(description='Restart ark server.')
parser.add_argument("--message", dest='message', default=None, help="Message to add to broadcast, usually reason for restart.")
parser.add_argument("--nodelay", dest='nodelay', default=False,
help="Run without delay.")
args = parser.parse_args()
if args.message:
args.message = args.message.strip()
if not args.message.endswith("."):
args.message = args.message + ". "
else:
args.message = args.message + " "
lock = Lock()
if lock.locked:
log.debug("Another script already running, exit...")
sys.exit()
print ("Starting...")
log.info("Admin initialized restart.")
lock.lock("Locked for restart...")
if args.nodelay == False:
broadcast(f"Server will restart in 60 minutes. {args.message}{choice(random_funny_bits)}", True)
time.sleep(30 * 60)
broadcast(f"Server will restart in 30 minutes. {args.message}{choice(random_funny_bits)}", True)
time.sleep(15 * 60)
broadcast(f"Server will restart in 15 minutes. {args.message}{choice(random_funny_bits)}", True)
time.sleep(10 * 60)
broadcast(f"Server will restart in 5 minutes. {args.message}{choice(random_funny_bits)}", True)
time.sleep(5 * 60)
broadcast(f"Server will restart in 10 seconds. {args.message}{choice(random_funny_bits)}", True)
for i in range(1, 10):
broadcast(f"Restart in {10 - i}...")
print ("Restarting...")
restart_server()
time.sleep(15 * 60)
print ("Remove lock...")
lock.unlock()