Skip to content

Commit

Permalink
Add 'shutdown' and 'status' methods for vPoller Proxy
Browse files Browse the repository at this point in the history
  • Loading branch information
dnaeon committed Jan 8, 2014
1 parent 8515306 commit 25bb393
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/vpoller-proxy
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def stop(endpoint):
"""
# The message we send to initiate the shutdown sequence
msg = { "cmd": "shutdown" }
msg = { "method": "proxy.shutdown" }

# Send out our message
client = VPollerClient(endpoint=endpoint, timeout=1000, retries=3)
Expand All @@ -82,7 +82,7 @@ def status(endpoint):
"""
# The message we send to get status information
msg = { "cmd": "status" }
msg = { "method": "proxy.status" }

# Send out our message
client = VPollerClient(endpoint=endpoint, timeout=1000, retries=3)
Expand Down
45 changes: 45 additions & 0 deletions src/vpoller/proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,3 +225,48 @@ def process_mgmt_message(self, msg):
result = methods[msg['method']] if methods.get(msg['method']) else "{ \"status\": -1, \"msg\": \"Uknown command received\" }"

return result

def get_proxy_status(self, msg):
"""
Get status information about the vPoller Proxy
Args:
msg (dict): The client message for processing (ignored)
Returns:
Status information about the vPoller Proxy
"""
result = '{ "success": 0, \
"msg": "vPoller Proxy Status", \
"result": {\
"status": "running", \
"hostname": "%s", \
"frontend_endpoint": "%s", \
"backend_endpoint": "%s", \
"mgmt_endpoint": "%s", \
"running_since": "%s", \
"uname": "%s" \
} \
}' % (os.uname()[1],
self.frontend_endpoint,
self.backend_endpoint,
self.mgmt_endpoint
self.running_since,
" ".join(os.uname()))
return result

def proxy_shutdown(self, msg):
"""
Shutdown the vPoller Worker
Args:
msg (dict): The client message for processing (ignored)
"""
logging.info("vPoller Proxy is shutting down")

self.time_to_die = True

return "{ \"success\": 0, \"msg\": \"vPoller Proxy is shutting down\" }"

0 comments on commit 25bb393

Please sign in to comment.