【发布时间】:2022-12-18 06:00:48
【问题描述】:
我一直在尝试在 Azure 上部署一个 Django 应用程序大约一个星期。我的讲师遵循了我使用的完全相同的设置,他能够将相同的应用程序部署到 Azure。
我遵循了几个教程,特别是this one from Digital Ocean,我总是得到相同的结果。当我访问 IP 地址时,我得到一个 502 Bad Gateway。我对本教程所做的唯一更改是打开端口 8000 和 80。我通过 Azure 的网络设置来做到这一点。
我已经尝试了该教程末尾的所有故障排除建议。我重新启动了 Gunicorn、Nginx,甚至是虚拟机。
在 Azure 上,我有一个运行 Ubuntu 22.04 的标准 B1s VM。我没有自定义域,只有 Azure 分配的静态 IP。
我可以很好地在开发服务器上部署该应用程序。如果我将 0.0.0.0:8000 绑定到 gunicorn,它也会显示该站点(减去样式)。
Gunicorn 启动并运行。当我在启动服务后检查状态时,它会显示活动的绿点。在尝试通过 IP 地址访问站点后,如果我再次检查 Gunicorn 状态,它会立即显示:gunicorn.socket: Failed with result 'service-start-limit-hit'
这就是我运行的sudo journalctl -fu gunicorn:
Dec 09 12:12:01 web-ubuntu22-vm1 gunicorn[33891]: raise HaltServer(reason, self.WORKER_BOOT_ERROR)
Dec 09 12:12:01 web-ubuntu22-vm1 gunicorn[33891]: gunicorn.errors.HaltServer: <HaltServer 'Worker failed to boot.' 3>
Dec 09 12:12:01 web-ubuntu22-vm1 systemd[1]: gunicorn.service: Main process exited, code=exited, status=1/FAILURE
Dec 09 12:12:01 web-ubuntu22-vm1 systemd[1]: gunicorn.service: Failed with result 'exit-code'.
Dec 09 12:12:01 web-ubuntu22-vm1 systemd[1]: gunicorn.service: Start request repeated too quickly.
Dec 09 12:12:01 web-ubuntu22-vm1 systemd[1]: gunicorn.service: Failed with result 'exit-code'.
Dec 09 12:12:01 web-ubuntu22-vm1 systemd[1]: Failed to start gunicorn daemon.
Dec 9 12:12:01 web-ubuntu22-vm1 systemd[1]: gunicorn.socket: Failed with result 'service-start-limit-hit'.
【问题讨论】:
标签: django nginx gunicorn azure-virtual-machine