Skip to content

Commit

Permalink
up
Browse files Browse the repository at this point in the history
  • Loading branch information
deploy committed Jun 18, 2019
1 parent e5a602d commit 8ada1ae
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 19 deletions.
Binary file removed app/.models.py.swp
Binary file not shown.
8 changes: 8 additions & 0 deletions app/hostscheck/crontab
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# deploy hosts check
* * * * * cd /app/deploy/app/hostscheck/;python service_check.py >> /data/log/service_check.log 2>&1
# deploy service check alarm
* * * * * cd /app/deploy/app/hostscheck/;python service_alarm.py >> /data/log/service_alarm.log 2>&1
# deploy consul check
* * * * * cd /app/deploy/app/hostscheck/;python consul_check.py >> /data/log/consul_check.log 2>&1
# deploy consul alarm
* * * * * cd /app/deploy/app/hostscheck/;python consul_alarm.py >> /data/log/consul_alarm.log 2>&1
51 changes: 33 additions & 18 deletions app/hostscheck/hostscheck.py → app/hostscheck/service_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,28 +169,43 @@ def executeSQL(self, sql="select * from `serverinfo` limit 1;"):
threadID += 1


try:
iplistall = requests.get(iplistallurl, timeout=2).json()
except Exception as err:
time.sleep(10)
print('ERROR: iplistall URL GET fail')
continue
queueLock.acquire()
try:
for ip in iplistall:
if ip not in notchecklist:
workQueue.put(ip, False)
except Exception as err:
print(str(err))
queueLock.release()



time.sleep(1)
while True:
queueLock.acquire()
print 'work q %s' % workQueue.qsize()
if workQueue.empty():
try:
iplistall = requests.get(iplistallurl, timeout=2).json()
except Exception as err:
time.sleep(10)
print('ERROR: iplistall URL GET fail')
continue
queueLock.acquire()
try:
for ip in iplistall:
if ip not in notchecklist:
workQueue.put(ip, False)
if workQueue.full():
print('ERROR: check host IP Queue %s full. clean IP Queue all' %(workQueue.qsize() ))
workQueue.queue.clear()
except Exception as err:
print(str(err))
break
else:
queueLock.release()
time.sleep(15)
time.sleep(1)

while True:
statusqueueLock.acquire()
print 'status q %s' % statusQueue.qsize()
if statusQueue.empty():
print 'exit'
os._exit(0)
else:
time.sleep(3)
statusqueueLock.release()
time.sleep(1)



exitFlag = 1
Expand Down
2 changes: 1 addition & 1 deletion app/main/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def deployConfig(project, host, ones, ones1, ones2):
if ones.type in supervisord_list:
# supervisor
supervisor_conf = ones2.supervisor.replace('$ip$',host).replace('$pnum$',ones1.pnum).replace('$env$',ones1.env)
supervisor_conf_path = '%s/%s_%s_supervisor.conf' %(project_path, project, host)
supervisor_conf_path = '/tmp/%s_%s_supervisor.conf' %(project, host)
remote_supervisor_conf_path = '%s@%s:%s/%s.conf' %(exec_user, host, supervisor_conf_dir, project)
writefile(supervisor_conf_path, supervisor_conf)

Expand Down

0 comments on commit 8ada1ae

Please sign in to comment.