Merge pull request #730 from ostcar/server_listen_device
Listen per default to the public
This commit is contained in:
commit
9485e771b9
@ -178,15 +178,10 @@ def _main(opts, database_path=None):
|
||||
|
||||
# Find url to openslides
|
||||
addr, port = detect_listen_opts(opts.address, opts.port)
|
||||
if port == 80:
|
||||
url = "http://%s" % addr
|
||||
else:
|
||||
url = "http://%s:%d" % (addr, port)
|
||||
|
||||
# Create Database if necessary
|
||||
if not database_exists() or opts.syncdb:
|
||||
run_syncdb()
|
||||
set_system_url(url)
|
||||
create_or_reset_admin_user()
|
||||
|
||||
# Reset Admin
|
||||
@ -205,7 +200,11 @@ def _main(opts, database_path=None):
|
||||
reload = False
|
||||
|
||||
if opts.start_browser:
|
||||
start_browser(url)
|
||||
if port == 80:
|
||||
suffix = ""
|
||||
else:
|
||||
suffix = ":%d" % port
|
||||
start_browser("http://localhost%s" % suffix)
|
||||
|
||||
# Start the server
|
||||
run_tornado(addr, port, reload)
|
||||
@ -252,10 +251,7 @@ def setup_django_environment(settings_path):
|
||||
|
||||
def detect_listen_opts(address=None, port=None):
|
||||
if address is None:
|
||||
try:
|
||||
address = socket.gethostbyname(socket.gethostname())
|
||||
except socket.error:
|
||||
address = "127.0.0.1"
|
||||
address = "0.0.0.0"
|
||||
|
||||
if port is None:
|
||||
# test if we can use port 80
|
||||
@ -298,15 +294,6 @@ def run_syncdb():
|
||||
execute_from_command_line(argv)
|
||||
|
||||
|
||||
def set_system_url(url):
|
||||
# can't be imported in global scope as it already requires
|
||||
# the settings module during import
|
||||
from openslides.config.api import config
|
||||
|
||||
if config['participant_pdf_system_url'] == 'http://example.com:8000':
|
||||
config['participant_pdf_system_url'] = url
|
||||
|
||||
|
||||
def create_or_reset_admin_user():
|
||||
# can't be imported in global scope as it already requires
|
||||
# the settings module during import
|
||||
|
@ -20,6 +20,7 @@ from tornado.options import options, parse_command_line
|
||||
|
||||
from django.core.handlers.wsgi import WSGIHandler as Django_WSGIHandler
|
||||
from django.conf import settings
|
||||
from django.utils.translation import ugettext as _
|
||||
|
||||
|
||||
class DjangoStaticFileHandler(StaticFileHandler):
|
||||
@ -41,6 +42,13 @@ def run_tornado(addr, port, reload=False):
|
||||
# Don't try to read the command line args from openslides
|
||||
parse_command_line(args=[])
|
||||
|
||||
# Print listening address and port to command line
|
||||
if addr == '0.0.0.0':
|
||||
url_string = _("the machine's local ip address")
|
||||
else:
|
||||
url_string = 'http://%s:%s' % (addr, port)
|
||||
print _("Starting OpenSlides' tornado webserver listening to %(url_string)s") % {'url_string': url_string}
|
||||
|
||||
# Start the application
|
||||
app = WSGIContainer(Django_WSGIHandler())
|
||||
tornado_app = Application([
|
||||
|
Loading…
Reference in New Issue
Block a user