Created
June 27, 2014 18:52
-
-
Save ConnorDoyle/219e6acb69399b51d89a to your computer and use it in GitHub Desktop.
Usage of `mesos ls` -- magic!
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
connor@iota:marathon (mesos-health-checks) $ mesos cat toggle\.8214d9c7-fe2b-11e3-b172-685b35a05cac toggle.py | |
import sys | |
import SimpleHTTPServer | |
from BaseHTTPServer import BaseHTTPRequestHandler | |
import SocketServer | |
import urlparse | |
PORT = int(sys.argv[1]) | |
healthy = True | |
class ToggleHandler(BaseHTTPRequestHandler): | |
def do_GET(self): | |
global healthy | |
parsed_path = urlparse.urlparse(self.path) | |
print "GET: [%s]\n" % parsed_path.path | |
if parsed_path.path == "/toggle": | |
healthy = not healthy | |
print "Setting health to [%s]\n" % healthy | |
self.send_response(200) | |
message = "Set health to [%s]" % healthy | |
elif healthy: | |
self.send_response(200) | |
message = "OK" | |
else: | |
self.send_response(410) | |
message = "Gone" | |
self.end_headers() | |
self.wfile.write(message) | |
return | |
httpd = SocketServer.TCPServer(("", PORT), ToggleHandler) | |
print "Bound to port [%s]" % PORT |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment