gunicorn active:失败,为什么不激活 gunicorn 服务?
gunicorn active: failed, why don`t active gunicorn service?
我有 ubuntu 服务器 20.04 和一个 Django 项目
我设置
/etc/systemd/system/gunicorn.套接字
Description=gunicorn socket
[Socket]
ListenStream=/run/gunicorn.sock
[Install]
WantedBy=sockets.target
和
/etc/systemd/system/gunicorn.service
[Unit]
Description=gunicorn daemon
Requires=gunicorn.socket
After=network.target
[Service]
User=sammy
Group=www-data
WorkingDirectory=/home/sammy/myprojectdir
ExecStart=/home/sammy/myprojectdir/myprojectenv/bin/gunicorn \
--access-logfile - \
--workers 3 \
--bind unix:/run/gunicorn.sock \
myproject.wsgi:application
[Install]
WantedBy=multi-user.target
我有这个错误
gunicorn.service - gunicorn daemon
Loaded: loaded (/etc/systemd/system/gunicorn.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Wed 2022-03-16 11:49:31 +0330; 12min ago
TriggeredBy: ● gunicorn.socket
Process: 1891 ExecStart=/home/sammy/myprojectdir/myprojectenv/bin/gunicorn --access-logfile - --workers 3 --bi> Main PID: 1891 (code=exited, status=217/USER)
Mar 16 11:49:31 srv174847 systemd[1]: Started gunicorn daemon.
Mar 16 11:49:31 srv174847 systemd[1891]: gunicorn.service: Failed to determine user credentials: No such process:: Failed to determine user credentials: No such process
Mar 16 11:49:31 srv174847 systemd[1891]: gunicorn.service: Failed at step USER spawning /home/sammy/myprojectdir/myprojectenv/bin/gunicorn: No such process
Mar 16 11:49:31 srv174847 systemd[1]: gunicorn.service: Main process exited, code=exited, status=217/USER
Mar 16 11:49:31 srv174847 systemd[1]: gunicorn.service: Failed with result 'exit-code'.
请帮帮我
问题是我在 gunicorn .service 文件中输入了错误的用户名。
还有一点就是我们select给gunicorn.service的用户必须是www-data组的成员,所以我们先用下面的命令查看这个组的成员:
```
grep ^www-data /etc/group
For example, we add user amir to the www-data group using the following command:
```
sudo adduser {USER-NAME-HERE} {GROUP-NAME-HERE}
sudo adduser amir www-data
我有 ubuntu 服务器 20.04 和一个 Django 项目
我设置
/etc/systemd/system/gunicorn.套接字
Description=gunicorn socket
[Socket]
ListenStream=/run/gunicorn.sock
[Install]
WantedBy=sockets.target
和
/etc/systemd/system/gunicorn.service
[Unit]
Description=gunicorn daemon
Requires=gunicorn.socket
After=network.target
[Service]
User=sammy
Group=www-data
WorkingDirectory=/home/sammy/myprojectdir
ExecStart=/home/sammy/myprojectdir/myprojectenv/bin/gunicorn \
--access-logfile - \
--workers 3 \
--bind unix:/run/gunicorn.sock \
myproject.wsgi:application
[Install]
WantedBy=multi-user.target
我有这个错误
gunicorn.service - gunicorn daemon
Loaded: loaded (/etc/systemd/system/gunicorn.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Wed 2022-03-16 11:49:31 +0330; 12min ago
TriggeredBy: ● gunicorn.socket
Process: 1891 ExecStart=/home/sammy/myprojectdir/myprojectenv/bin/gunicorn --access-logfile - --workers 3 --bi> Main PID: 1891 (code=exited, status=217/USER)
Mar 16 11:49:31 srv174847 systemd[1]: Started gunicorn daemon.
Mar 16 11:49:31 srv174847 systemd[1891]: gunicorn.service: Failed to determine user credentials: No such process:: Failed to determine user credentials: No such process
Mar 16 11:49:31 srv174847 systemd[1891]: gunicorn.service: Failed at step USER spawning /home/sammy/myprojectdir/myprojectenv/bin/gunicorn: No such process
Mar 16 11:49:31 srv174847 systemd[1]: gunicorn.service: Main process exited, code=exited, status=217/USER
Mar 16 11:49:31 srv174847 systemd[1]: gunicorn.service: Failed with result 'exit-code'.
请帮帮我
问题是我在 gunicorn .service 文件中输入了错误的用户名。 还有一点就是我们select给gunicorn.service的用户必须是www-data组的成员,所以我们先用下面的命令查看这个组的成员: ``` grep ^www-data /etc/group
For example, we add user amir to the www-data group using the following command:
```
sudo adduser {USER-NAME-HERE} {GROUP-NAME-HERE}
sudo adduser amir www-data