Skip to content

Commit

Permalink
switch back to eventlet wgsi server
Browse files Browse the repository at this point in the history
  • Loading branch information
Stefal committed Jun 10, 2024
1 parent 608388f commit 3c0c156
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
17 changes: 12 additions & 5 deletions web_app/gnss_rproxy_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@
# Reverse proxy server to acces a Gnss receiver integrated Web Server (Mosaic-X5 or other)

import os
#from gevent import monkey
#monkey.patch_all()
import eventlet
eventlet.monkey_patch()
from eventlet import wsgi
import requests

from RTKBaseConfigManager import RTKBaseConfigManager
Expand All @@ -20,7 +25,7 @@
from flask_login import LoginManager, login_user, logout_user, login_required, current_user, UserMixin
from wtforms.validators import ValidationError, DataRequired, EqualTo
import urllib
import gunicorn.app.base
#import gunicorn.app.base

from werkzeug.security import generate_password_hash
from werkzeug.security import check_password_hash
Expand All @@ -41,9 +46,8 @@
#Get settings from settings.conf.default and settings.conf
rtkbaseconfig = RTKBaseConfigManager(os.path.join(rtkbase_path, "settings.conf.default"), os.path.join(rtkbase_path, "settings.conf"))
GNSS_RCV_WEB_URL = str("{}{}".format("http://", rtkbaseconfig.get("main", "gnss_rcv_web_ip")))

"""
class StandaloneApplication(gunicorn.app.base.BaseApplication):
""" Class for starting gunicorn from inside a script """
def __init__(self, app, options=None):
self.options = options or {}
self.application = app
Expand All @@ -57,7 +61,7 @@ def load_config(self):
def load(self):
return self.application

"""
class User(UserMixin):
""" Class for user authentification """
def __init__(self, username):
Expand Down Expand Up @@ -156,14 +160,17 @@ def logout():
app.config["LOGIN_DISABLED"] = True

app.secret_key = rtkbaseconfig.get_secret_key()
#socketio.run(app, host = "::", port = args.port or rtkbaseconfig.get("general", "web_port", fallback=80), debug=args.debug) # IPv6 "::" is mapped to IPv4
wsgi.server(eventlet.listen(("0.0.0.0", int(rtkbaseconfig.get("main", "gnss_rcv_web_proxy_port", fallback=9090)))), app, log_output=False)

gunicorn_options = {
'bind': ['%s:%s' % ('0.0.0.0', rtkbaseconfig.get("main", "gnss_rcv_web_proxy_port", fallback=9090)),
'%s:%s' % ('[::1]', rtkbaseconfig.get("main", "gnss_rcv_web_proxy_port", fallback=9090)) ],
'workers': 1,
'loglevel': 'warning',
}
#start gunicorn
StandaloneApplication(app, gunicorn_options).run()
#StandaloneApplication(app, gunicorn_options).run()

except KeyboardInterrupt:
print("Server interrupted by user!!")
Expand Down
1 change: 0 additions & 1 deletion web_app/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ Flask-SocketIO==5.3.6
Flask-WTF==1.2.1;python_version>="3.8"
Flask-WTF==1.1.1;python_version<"3.8"
greenlet==3.0.1
gunicorn==22.0.0
h11==0.14.0
idna==3.7
importlib-metadata==6.7.0;python_version<"3.8"
Expand Down

0 comments on commit 3c0c156

Please sign in to comment.