Opened 7 years ago

Closed 7 years ago

#7 closed task (fixed)

add daemon for cockpit

Reported by: zhangjr Owned by:
Priority: major Milestone:
Version: Keywords:
Cc: Blocked By:
Blocking: Parent ID:
Parent Tickets: Estimated Number of Hours: 0.0
Add Hours to Ticket: 0 Billable?: yes
Total Hours: 0

Description (last modified by zhangjr)

cockpitDaemon enable monitor the 'restart' command from web.

Subtickets

Child Tickets

Change History (2)

comment:1 Changed 7 years ago by zhangjr

  • Description modified (diff)

#!/usr/bin/python
import sys
import time
import threading
import subprocess
class main(threading.Thread):

def init(self):

threading.Thread.init(self)
self.lastTimeStamp='---'


from redis.sentinel import Sentinel


try:

sentinel = Sentinel([('10.1.33.141', 9001)], socket_timeout=0.1)
self.redisServer=sentinel.master_for('neonmaster', socket_timeout=30, password="sanlie;123")

except:

print "Redis server failed"
sys.exit()


def restartCockpit(self):

_cmd="source /home/neon/workspace/cockpit/cockpit"
subprocess.Popen(_cmd, shell=True)


def run(self):

#self.redisServer.set("/GPPD/cockpit/log", " ")
while True:

_TimeStamp=self.redisServer.get("/GPPD/cockpit/restart")
if _TimeStamp!='notset':

self.restartCockpit()
self.redisServer.set("/GPPD/cockpit/restart", "notset")

time.sleep(2.0)

if name=="main":

threadDaemon = main()
threadDaemon.setDaemon(True)
threadDaemon.start()
threadDaemon.join()
sys.exit()

comment:2 Changed 7 years ago by zhangjr

  • Resolution set to fixed
  • Status changed from new to closed
Note: See TracTickets for help on using tickets.