Permalink
Cannot retrieve contributors at this time
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
60 lines (48 sloc)
1.68 KB
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
import psutil | |
import time | |
import tornado.ioloop | |
import tornado.web | |
_processes_ = [ | |
["Node", "node"], | |
["Casino Interface", "zircodice_web.py"], | |
["Casino Engine", "zircodice_dappie.py"], | |
["Ledger Explorer", "ledger_explorer.py"], | |
["Wallet", "wallet.py"], | |
["Anonymizer", "anon_dappie.py"], | |
["HTML Interpreter", "html_dappie.py"], | |
["Geo", "geo.py"], | |
["Bisdom", "bisdom.py"], | |
["Twitter Bot", "twitterizer.py"], | |
["Wallet Server", "wallet_server.py"]] | |
class MainHandler(tornado.web.RequestHandler): | |
def write_status(self, name, stat): | |
color = 'green' if stat else 'red' | |
stat = 'OK' if stat else 'Not running' | |
self.write("<font color='{}'>"\ | |
"{}: <strong>{}</strong>"\ | |
"</font>"\ | |
"<br>".format(color, stat, name)) | |
def get(self): | |
pnames = [] | |
del pnames [:] | |
for process in psutil.pids(): | |
try: | |
p = psutil.Process(process) # The pid of desired process | |
pnames.append(p.cmdline()) | |
except: | |
pass | |
for process in _processes_: | |
name, fn = process | |
self.write_status(name, fn in str(pnames)) | |
last_updated = time.strftime("%Y/%m/%d,%H:%M:%S", time.gmtime(time.time())) | |
self.write("<br>"\ | |
"Last updated: {}".format(last_updated)) | |
def make_app(): | |
return tornado.web.Application([ | |
(r"/", MainHandler), | |
(r"/static/(.*)", tornado.web.StaticFileHandler, {"path": "static"}), | |
]) | |
if __name__ == "__main__": | |
app = make_app() | |
app.listen(80) | |
tornado.ioloop.IOLoop.current().start() |