我使用docker-compose将每个图像绑定一次以启动。
在python中,我使用uwsgi部署了Flask Web服务器。
[manage.py]
import unittest
from app.main import create_app, db
from app.main.model import user
from flask_script import Manager
from app import blueprint
app = create_app(os.getenv('BOILERPLATE_ENV') or 'dev')
app.register_blueprint(blueprint)
app.app_context().push()
manager = Manager(app)
@manager.command
def run():
app.run(host='0.0.0.0')
@manager.command
def test():
"""Runs the unit tests."""
tests = unittest.TestLoader().discover('app/test', pattern='test*.py')
result = unittest.TextTestRunner(verbosity=2).run(tests)
if result.wasSuccessful():
return 0
return 1
if __name__ == '__main__':
manager.run()
如您所知,我使用flask-script Manager。
因此,当我执行flaks服务器时,请执行以下命令-> python3 manage.py run
[uwsgi.ini]
[uwsgi]
chdir = /home
http-socket = :5001
chmod-socket = 777
logto = /home/web.log
process = 2
wsgi-file = manage.py
callable = manager
daemonize = /home/uwsgi.log
lazy-apps = true
pyargv = run
我设置了wsgi-file = manage.py
和callable = manager
。
还设置pyargv = run
与python3 manage.py run
相同
但是当我运行服务器并访问Web时,它会引发错误。
TypeError: __call__() takes from 1 to 2 positional arguments but 3 were given
完整日志在这里。
root@web_project_dev:/home# uwsgi --ini config/uwsgi.ini
[uWSGI] getting INI configuration from config/uwsgi.ini
root@web_project_dev:/home# tail -f uwsgi.log
*** WARNING: you are running uWSGI as root !!! (use the --uid flag) ***
your server socket listen backlog is limited to 100 connections
your mercy for graceful operations on workers is 60 seconds
mapped 72920 bytes (71 KB) for 1 cores
*** Operational MODE: single process ***
uWSGI running as root, you can use --uid/--gid/--chroot options
*** WARNING: you are running uWSGI as root !!! (use the --uid flag) ***
*** uWSGI is running in multiple interpreter mode ***
spawned uWSGI worker 1 (and the only) (pid: 65, cores: 1)
WSGI app 0 (mountpoint='') ready in 0 seconds on interpreter 0x55588beca210 pid: 65 (default app)
TypeError: __call__() takes from 1 to 2 positional arguments but 3 were given
[pid: 65|app: 0|req: 1/1] 192.168.192.4 () {40 vars in 746 bytes} [Tue Nov 13 05:20:44 2018] GET / => generated 0 bytes in 0 msecs (HTTP/1.0 500) 0 headers in 0 bytes (0 switches on core 0)
如何将命令行参数插入uwsgi.ini?
谢谢。