scrapyd: support bind to a specific ip address

This commit is contained in:
lostsnow 2012-02-29 13:47:40 +08:00
parent 81abb45000
commit 5afe4f50c1
2 changed files with 8 additions and 2 deletions

View File

@ -153,6 +153,11 @@ http_port
The TCP port where the HTTP JSON API will listen. Defaults to ``6800``.
bind_address
------------
The IP address where the HTTP JSON API will listen. Defaults to ``0.0.0.0`` (all)
max_proc
--------

View File

@ -15,6 +15,7 @@ from .config import Config
def application(config):
app = Application("Scrapyd")
http_port = config.getint('http_port', 6800)
bind_address = config.get('bind_address', '0.0.0.0')
poller = QueuePoller(config)
eggstorage = FilesystemEggStorage(config)
@ -28,8 +29,8 @@ def application(config):
launcher = Launcher(config, app)
timer = TimerService(5, poller.poll)
webservice = TCPServer(http_port, server.Site(Root(config, app)))
log.msg("Scrapyd web console available at http://localhost:%s/" % http_port)
webservice = TCPServer(http_port, server.Site(Root(config, app)), interface=bind_address)
log.msg("Scrapyd web console available at http://%s:%s/" % (bind_address, http_port))
launcher.setServiceParent(app)
timer.setServiceParent(app)