【发布时间】:2015-03-25 02:23:10
【问题描述】:
我正在尝试使用 uWSGI 部署我的 Flask 应用程序,但如果没有 sudo,我似乎无法做到这一点。
这是我的启动脚本:
#!/bin/bash
set -v
set -e
cd /var/hpit/hpit_services
/var/hpit/hpit_services/env/bin/uwsgi --http [::]:80 --master --module wsgi --callable app --processes 4 --daemonize ../log/uwsgi.log --pidfile ../server_pid_file.pid
echo server started
这是我在日志中得到的:
*** Starting uWSGI 2.0.9 (64bit) on [Mon Jan 26 15:53:26 2015] ***
compiled with version: 4.8.2 on 23 January 2015 20:35:44
os: Linux-3.18.1-x86_64-linode50 #1 SMP Tue Jan 6 12:14:10 EST 2015
nodename: <<blocked out>>
machine: x86_64
clock source: unix
detected number of CPU cores: 2
current working directory: /var/hpit/hpit_services
writing pidfile to ../server_pid_file.pid
detected binary path: /var/hpit/hpit_services/env/bin/uwsgi
!!! no internal routing support, rebuild with pcre support !!!
your processes number limit is 7962
your memory page size is 4096 bytes
detected max file descriptor number: 1024
lock engine: pthread robust mutexes
thunder lock: disabled (you can enable it with --thunder-lock)
bind(): Permission denied [core/socket.c line 764]
Core/socket.c 第 764 行有这个:
if (bind(serverfd, (struct sockaddr *) &uws_addr, addr_len) != 0) {
if (errno == EADDRINUSE) {
uwsgi_log("probably another instance of uWSGI is running on the same address (%s).\n", socket_name);
}
uwsgi_error("bind()");
uwsgi_nuclear_blast();
return -1;
}
但我没有运行 uWSGI 的实例。这似乎是一个权限问题。我对 /var/hpit、/var/hpit/hpit_services(应用程序的位置)和 /var/hpit/log 的权限是 bsauer:www-data。我的用户我们是 bsauer。
如果我将sudo -E 附加到我的启动脚本中调用uWSGI 二进制文件的行,它似乎可以正常启动,但我读到服务器不应该以sudo 启动。我在工作中继承了这个系统管理员角色,对这一切有点陌生。
这是我的预感/沉思:
- 我知道 uWSGI 可以从一个用户开始,然后进入另一个用户角色,但我不太了解这个过程,所以也许这就是问题所在。
- uWSGI 正在尝试访问我不知道的系统上的某些内容
感谢您的帮助,如有需要,我可以提供更多详细信息。
编辑
奇怪的是,我的 /var/hpit/log/uwsgi.log 文件归 bsauer:bsauer 所有,而不是我预期的 bsauer:www-data 或 www-data:www-data...
EDIT2
好的,从页面底部的http://projects.unbit.it/uwsgi/wiki/Example 看来,问题似乎在端口 80 上运行。我将其更改为 8080,但它仍然以 bsauer 运行,我认为我不想要.
【问题讨论】: