@@ -25,7 +25,10 @@ def run(
25
25
port = 5000 ,
26
26
flask_config = None ,
27
27
install_dependencies = True ,
28
- upgrade_db = True
28
+ upgrade_db = True ,
29
+ uwsgi = False ,
30
+ uwsgi_mode = 'http' ,
31
+ uwsgi_extra_options = '' ,
29
32
):
30
33
"""
31
34
Run Example RESTful API Server.
@@ -56,11 +59,25 @@ def run(
56
59
)
57
60
58
61
use_reloader = app .debug
59
- if platform .system () == 'Windows' :
60
- warnings .warn (
61
- "Auto-reloader feature doesn't work on Windows. "
62
- "Follow the issue for more details: "
63
- "https://github.com/frol/flask-restplus-server-example/issues/16"
64
- )
65
- use_reloader = False
66
- app .run (host = host , port = port , use_reloader = use_reloader )
62
+ if uwsgi :
63
+ uwsgi_args = [
64
+ "uwsgi" ,
65
+ "--need-app" ,
66
+ "--manage-script-name" ,
67
+ "--mount" , "/=app:create_app()" ,
68
+ "--%s-socket" % uwsgi_mode , "%s:%d" % (host , port ),
69
+ ]
70
+ if use_reloader :
71
+ uwsgi_args += ["--python-auto-reload" , "2" ]
72
+ if uwsgi_extra_options :
73
+ uwsgi_args += uwsgi_extra_options .split (' ' )
74
+ os .execvpe ('uwsgi' , uwsgi_args , os .environ )
75
+ else :
76
+ if platform .system () == 'Windows' :
77
+ warnings .warn (
78
+ "Auto-reloader feature doesn't work on Windows. "
79
+ "Follow the issue for more details: "
80
+ "https://github.com/frol/flask-restplus-server-example/issues/16"
81
+ )
82
+ use_reloader = False
83
+ return app .run (host = host , port = port , use_reloader = use_reloader )
0 commit comments