数字海洋码头图像的主管

时间:2016-08-22 14:00:51

标签: django docker supervisor cookiecutter-django

(初学者问题)

我已在Digital Ocean液滴上成功设置了nginx + gunicorn + django泊坞窗图像。

我的Django项目遵循非常好的Cookie-Cutter-Django模式(see here)。

In this doc,有一个主管安装的描述。

我在这里缺少的是主管应该在哪里运行?本地还是远程?

据我所知,如果我在我的笔记本电脑上安装主管,它将“保持活力”我的命令“docker-compose up”。

但是,如果我休息一周,我的笔记本电脑电量耗尽怎么办?

主管会停止工作吗?

如果是这样,我需要在我的Droplet上安装它,对吗?

2 个答案:

答案 0 :(得分:1)

主管应该在您的Droplet上运行。它将确保您的Web服务器在被中断时自动重启。示例配置类似于this excellent blog post中的以下内容:

[program:hello]
command = /webapps/hello_django/bin/gunicorn_start                    ; Command to start app
user = hello                                                          ; User to run as
stdout_logfile = /webapps/hello_django/logs/gunicorn_supervisor.log   ; Where to write log messages
redirect_stderr = true                                                ; Save stderr in the same log
environment=LANG=en_US.UTF-8,LC_ALL=en_US.UTF-8                       ; Set UTF-8 as default encoding

答案 1 :(得分:0)

我有点困惑。 这篇SO帖子很有帮助:Is supervisord needed for docker+gunicorn+nginx? 至于这个tuto:https://blog.codeship.com/ensuring-containers-are-always-running-with-dockers-restart-policy/

我现在在compose.yml文件中添加了“restart:always”:

  redis:
    image: redis:latest
    restart: always