Python 主管:尝试启动 gunicorn 时出现错误(生成错误)

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/47581053/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-19 18:16:02  来源:igfitidea点击:

Supervisor: ERROR (spawn error) when trying to launch gunicorn

pythonflaskgunicornsupervisord

提问by peachykeen

I have been trying to setup gunicorn with supervisor per these instructions. However when I run

我一直在尝试按照这些说明与主管一起设置 gunicorn 。但是当我跑

sudo supervisorctl reread
sudo supervisorctl update
sudo supervisorctl start Server-CardLearning

I get the error Server-CardLearning: ERROR (spawn error).

我收到错误Server-CardLearning: ERROR (spawn error)

My configuration file is simple.

我的配置文件很简单。

[program:Server-CardLearning]
command = gunicorn app:app -b localhost:8000
directory = /home/alexg/www/<flask project>
user = www-data

I get the following errors in my log file.

我的日志文件中出现以下错误。

...
...
2017-11-30 13:48:52,276 INFO gave up: Server-CardLearning entered FATAL state, too many start retries too quickly
2017-11-30 13:49:10,595 INFO spawnerr: unknown error making dispatchers for 'Server-CardLearning': ENOENT
2017-11-30 13:49:11,597 INFO spawnerr: unknown error making dispatchers for 'Server-CardLearning': ENOENT
2017-11-30 13:49:13,599 INFO spawnerr: unknown error making dispatchers for 'Server-CardLearning': ENOENT
2017-11-30 13:49:16,603 INFO spawnerr: unknown error making dispatchers for 'Server-CardLearning': ENOENT
2017-11-30 13:49:16,603 INFO gave up: Server-CardLearning entered FATAL state, too many start retries too quickly
2017-11-30 13:58:12,101 INFO spawned: 'Server-CardLearning' with pid 13725
2017-11-30 13:58:12,560 INFO exited: Server-CardLearning (exit status 3; not expected)
2017-11-30 13:58:13,563 INFO spawned: 'Server-CardLearning' with pid 13730
2017-11-30 13:58:13,982 INFO exited: Server-CardLearning (exit status 3; not expected)
2017-11-30 13:58:15,986 INFO spawned: 'Server-CardLearning' with pid 13735
2017-11-30 13:58:16,411 INFO exited: Server-CardLearning (exit status 3; not expected)
2017-11-30 13:58:19,416 INFO spawned: 'Server-CardLearning' with pid 13742
2017-11-30 13:58:19,842 INFO exited: Server-CardLearning (exit status 3; not expected)
2017-11-30 13:58:20,843 INFO gave up: Server-CardLearning entered FATAL state, too many start retries too quickly
...
...
2017-11-30 14:10:29,728 INFO spawned: 'Server-CardLearning' with pid 13901
2017-11-30 14:10:29,957 INFO exited: Server-CardLearning (exit status 2; not expected)
2017-11-30 14:10:30,961 INFO spawned: 'Server-CardLearning' with pid 13902
2017-11-30 14:10:31,193 INFO exited: Server-CardLearning (exit status 2; not expected)
2017-11-30 14:10:33,200 INFO spawned: 'Server-CardLearning' with pid 13903
2017-11-30 14:10:33,436 INFO exited: Server-CardLearning (exit status 2; not expected)
2017-11-30 14:10:36,443 INFO spawned: 'Server-CardLearning' with pid 13904
2017-11-30 14:10:36,681 INFO exited: Server-CardLearning (exit status 2; not expected)
2017-11-30 14:10:37,682 INFO gave up: Server-CardLearning entered FATAL state, too many start retries too quickly

Where am I going wrong? I have tried some things I saw on stack overflow, but nothing proved to be relevant to this problem.

我哪里错了?我尝试了一些我在堆栈溢出中看到的东西,但没有证明与这个问题相关。

回答by peachykeen

The root of the problem seemed to be that I had an issue with app.py. I was using some Flask library that I had installed on my local machine but not the server and for some reason I didn't get big errors when I ran the server via flask run --host=0.0.0.0.

问题的根源似乎是我对app.py. 我使用的是我在本地机器上安装的一些 Flask 库,但没有安装在服务器上,由于某种原因,当我通过flask run --host=0.0.0.0.

I figured this out by adjusting supervisor .conffile which is located at /etc/supervisor/conf.d/Server-CardLearning.conf

我通过调整.conf位于/etc/supervisor/conf.d/Server-CardLearning.conf

The new .conffile reads:

.conf文件内容如下:

[program:Server-CardLearning]
environment=SECRET_KEY="some_secret_key"
command=gunicorn app:app -b localhost:8000
directory=/home/alexg/www/Server-CardLearning
user=alexg
autostart=true
stderr_logfile=/var/log/supervisor/test.err.log
stdout_logfile=/var/log/supervisor/test.out.log

By adding the two log files I was able to run:

通过添加两个日志文件,我能够运行:

cat /var/log/supervisor/test.err.log

cat /var/log/supervisor/test.err.log

to see that I had an uninstalled library! ~Gasp!~

看到我有一个卸载的库!~喘气!~

After installing the library, I ran:

安装库后,我运行:

sudo supervisorctl reread
sudo supervisorctl update
sudo supervisorctl start Server-CardLearning

Now, if that doesn't fix it, I also found that digging around in the supervisor console was helpful:

现在,如果这不能解决它,我还发现在主管控制台中挖掘是有帮助的:

$ sudo supervisorctl
supervisor> help
supervisor> status

I hope this helps someone out!

我希望这可以帮助别人!