1
0
Fork 0

Use Twisted WSGI directly

This commit is contained in:
Luca Beltrame 2015-05-20 07:40:52 +02:00
parent bcdae9caaf
commit 659eed4d95

View file

@ -10,6 +10,10 @@ from flask import Flask, request
from pid import PidFile from pid import PidFile
import sarge import sarge
from systemd.journal import JournalHandler from systemd.journal import JournalHandler
from twisted.internet import reactor
from twisted.web.server import Site
from twisted.web.wsgi import WSGIResource
DESTINATION = "/var/www/dennogumi-test/" DESTINATION = "/var/www/dennogumi-test/"
REPO = "dennogumi.org" REPO = "dennogumi.org"
@ -33,7 +37,7 @@ def push_hook_to_server():
app.logger.info("Cloning repository...") app.logger.info("Cloning repository...")
git.Repo.clone_from(repo_url, temp) git.Repo.clone_from(repo_url, temp)
cmd = "/home/einar/bin/jekyll_clone_repo.sh {0} {1}" cmd = "/usr/bin/jekyll_clone_repo.sh {0} {1}"
cmd = sarge.shell_format(cmd, temp, DESTINATION) cmd = sarge.shell_format(cmd, temp, DESTINATION)
app.logger.info("Deploying Jekyll...") app.logger.info("Deploying Jekyll...")
pid = sarge.run(cmd, async=True) pid = sarge.run(cmd, async=True)
@ -41,7 +45,9 @@ def push_hook_to_server():
return "OK" return "OK"
if __name__ == "__main__": if __name__ == "__main__":
with PidFile("/run/webhook/jekyll_webhook.pid", chmod=0o600):
handler = JournalHandler() resource = WSGIResource(reactor, reactor.getThreadPool(), app)
app.logger.addHandler(handler) site = Site(resource)
app.run()
reactor.listenTCP(5000, site, interface="127.0.0.1")
reactor.run()