-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnode_server_end.py
More file actions
28 lines (28 loc) · 866 Bytes
/
Copy pathnode_server_end.py
File metadata and controls
28 lines (28 loc) · 866 Bytes
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
import datetime
import time
import mysql.connector
from mysql.connector import errorcode
from shutil import copyfile
import os
while True:
try:
cnx = mysql.connector.connect(user='uopAdmin123', password='pandu123', host='uopinstance.cisutjhhzfjh.us-west-2.rds.amazonaws.com',database='voterdb')
except mysql.connector.Error as err:
print err
cursor = cnx.cursor()
query = ('SELECT * FROM event_details WHERE running=true')
cursor.execute(query)
result = cursor.fetchall()
cursor.close()
if len(result) == 0:
time.sleep(10)
continue
for each_row in result:
os.system("rm ./nodesetup_"+each_row[0]+".js")
os.system('pm2 delete nodesetup_'+each_row[0])
cursor = cnx.cursor()
cursor.execute('update event_details set running=false where event_id="'+each_row[0]+'"')
cursor.close()
cnx.commit()
print datetime.datetime.now()
time.sleep(10)