-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathservice.py
32 lines (24 loc) · 884 Bytes
/
service.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
#!/usr/bin/env python
# win32 basic sample (TODO: make a real win32 service)
# configure these paths:
LOGFILE = None # stdout o 'C:/pyreplica/pyreplica.log'
PIDFILE = 'C:/pyreplica/pyreplica.pid'
CONFPATH = 'C:/pyreplica'
DEBUG_LEVEL = 2 # default debug level: 1: normal, 2: verbose
import sys, os
from daemon import Log, Replicator
if __name__ == "__main__":
#redirect outputs to a logfile
if LOGFILE:
sys.stdout = sys.stderr = Log(open(LOGFILE, 'a+'))
# start replication threads
config_files = [f for f in os.listdir(CONFPATH) if f.endswith(".conf")]
threads = []
for config_file in config_files:
thread = Replicator(os.path.join(CONFPATH,config_file))
threads.append(thread)
thread.start()
for thread in threads:
# wait until it terminates
thread.join()
print "Threads killed ok"