【发布时间】:2019-04-02 09:23:12
【问题描述】:
我试图在我的 EC2 实例内启动时运行 gunicorn,我在 /lib/systemd/system/ 中创建了一个看起来像这样的 myproject.service 文件。
[Unit]
Description="my startup file"
[Service]
WorkingDirectory=/home/ubuntu/myproject
Type=simple
ExecStart=/home/ubuntu/.local/bin/gunicorn -w 1 -b 0.0.0.0:8080 wsgi:application
[Install]
WantedBy=multi-user.target
为了测试它是否工作,我一直在运行这些命令
sudo systemctl daemon-reload
sudo systemctl start myproject
sudo systemctl status myproject
这会返回错误
Apr 02 09:14:13 ip-172-31-32-45 gunicorn[5827]: File "/home/ubuntu/.local/bin/gunicorn", line 7, in <module>
Apr 02 09:14:13 ip-172-31-32-45 gunicorn[5827]: from gunicorn.app.wsgiapp import run
Apr 02 09:14:13 ip-172-31-32-45 gunicorn[5827]: ModuleNotFoundError: No module named 'gunicorn'
Apr 02 09:14:13 ip-172-31-32-45 systemd[1]: myproject.service: Main process exited, code=exited, status=1/FAILURE
Apr 02 09:14:13 ip-172-31-32-45 systemd[1]: myproject.service: Failed with result 'exit-code'.
我使用which gunicorn返回绝对路径,所以我不明白为什么没有找到gunicorn
【问题讨论】:
标签: amazon-ec2 gunicorn systemd