~launchpad-pqm/lazr-js/toolchain

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import os

from lazr.js.combo import combo_app

from twisted.application import service, strports
from twisted.internet import reactor
from twisted.python import threadpool
from twisted.web import server, wsgi
from twisted.web.static import File
from twisted.web.resource import Resource


resource = Resource()
for path in os.listdir("build"):
    folder = os.path.join("build", path)
    if os.path.isdir(folder):
        resource.putChild(path, File(folder))

threadpool = threadpool.ThreadPool(0, 10)
threadpool.start()
reactor.addSystemEventTrigger("during", "shutdown", threadpool.stop)

resource.putChild("combo", wsgi.WSGIResource(reactor, threadpool,
                                             combo_app("build")))

application = service.Application("combo-service")
site = server.Site(resource)

s = strports.service("tcp:9876", site)
s.setServiceParent(application)