Last active
December 15, 2015 09:58
-
-
Save mhils/5242278 to your computer and use it in GitHub Desktop.
untested
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
from bottle import route, run, debug | |
from os import system | |
from time import time | |
import psutil | |
debug(False) | |
auth = 'changeme' | |
@route('/restart/:secret') | |
def restart(secret): | |
if secret != auth: | |
return "wrong secret" | |
honeyproxy_processes = filter(lambda x: x.name in "python" and any("honeyproxy.py" in y for y in x.cmdline), psutil.process_iter()) | |
for p in honeyproxy_processes: | |
p.kill() | |
t = time() | |
system("nohup python honeyproxy/honeyproxy.py --api-auth %s -w %d.dump > %d.log 2> %d.err < /dev/null &" % (auth, t, t, t)) | |
return "instance resetted." | |
run(host='0.0.0.0', port=8000) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment