【问题标题】:uWSGI runs Django project from command line but not from Emperor uwsgi.service fileuWSGI 从命令行而不是从 Emperor uwsgi.service 文件运行 Django 项目
【发布时间】:2019-08-05 14:55:48
【问题描述】:

我正在使用uwsgi and NGINX 为我的Django 项目在Ubuntu 16.04 上运行virtualenvPython3.6

我已经在全球范围内安装了uWSGI,也在virtualenv.中安装了

我可以在 env 中使用 uWSGI 从命令行运行我的项目

/home/user/Env/myproject/bin/uwsgi --http :8080 --home /home/user/Env/myproject --chdir /home/user/myproject/src/myproject -w myproject.wsgi

并转到我的域,它加载正常。

但是我显然在“皇帝模式”下运行 uWSGI,当我设置服务文件(连同 NGINX)时,域显示internal server error

uWSGI 日志跟踪到--- no python application found ---

我在运行时遇到了这个问题

uwsgi --http :8080 --home /home/user/Env/myproject --chdir /home/user/myproject/src/myproject -w myproject.wsgi

因为它使用的是全局安装 uwsgi 而不是 virtualenv。

我将我的 StartExec 更改为 virtualenv uwsgi 路径,但没有运气。

我不知道我做错了什么,路径错误?语法错误?

我的/etc/systemd/system/uwsgi.service 文件

[Unit]
Description=uWSGI Emperor service

[Service]
ExecStartPre=/bin/bash -c 'mkdir -p /run/uwsgi; chown user:www-data /run/uwsgi'
ExecStart=/home/user/Env/myproject/bin/uwsgi --emperor /etc/uwsgi/sites
Restart=always
KillSignal=SIGQUIT
Type=notify
NotifyAccess=all

[Install]
WantedBy=multi-user.target

【问题讨论】:

  • --emperor /etc/uwsgi/sites 实际上是做什么的?你的 .ini 文件在哪里指定,它告诉 uwsgi virtualenv 在哪里?

标签: python django virtualenv uwsgi


【解决方案1】:

好吧有点傻,但似乎我运行了sudo systemctl stop uwsgi,然后运行了sudo systemctl start uwsgi,现在它可以工作了。

【讨论】:

  • 嗯,当您更改配置时,您总是需要重新启动 systemd 守护进程。确实很傻。 ;)
  • @dirkgroten 计算机时间过多会让你又傻又健忘! Ta 并感谢 Dirk 的帮助 :)
猜你喜欢
  • 1970-01-01
  • 2018-03-03
  • 1970-01-01
  • 2012-11-30
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多