简体   繁体   English

龙卷风代码部署

[英]Tornado code deployment

Is there a canonical code deployment strategy for tornado-based web application deployment. 是否存在基于龙卷风的Web应用程序部署的规范代码部署策略。 Our current configuration is 4 tornado processes running behind NginX? 我们目前的配置是在NginX后面运行的4个龙卷风进程? (Our specific use case is behind EC2.) (我们的具体用例是EC2背后的。)

We've currently got a solution that works well enough, whereby we launch the four tornado processes and save the PIDs to a file in /tmp/. 我们目前有一个运行良好的解决方案,我们启动四个龙卷风进程并将PID保存到/ tmp /中的文件。 Upon deploying new code, we run the following sequence via fabric: 在部署新代码时,我们通过结构运行以下序列:

  1. Do a git pull from the prod branch. 从prod分支做一个git pull。
  2. Remove the machine from the load balancer. 从负载平衡器中卸下机器。
  3. Wait for all in flight connections to finish with a sleep. 等待所有飞行中的连接完成睡眠。
  4. Kill all the tornadoes in the pid file and remove all *.pyc files. 杀死pid文件中的所有龙卷风并删除所有* .pyc文件。
  5. Restart the tornadoes. 重启龙卷风。
  6. Attach the machine back to the load balancer. 将机器连接回负载平衡器。

We've taken some inspiration from this: http://agiletesting.blogspot.com/2009/12/deploying-tornado-in-production.html 我们从中获得了一些灵感: http//agiletesting.blogspot.com/2009/12/deploying-tornado-in-production.html

Are there any other complete solutions out there? 那里还有其他完整的解决方案吗?

We run Tornado+Nginx with supervisord as the supervisor. 我们以supervisord作为主管运行Tornado + Nginx。

Sample configuration (names changed) 示例配置(名称已更改)

[program:server]
process_name = server-%(process_num)s
command=/opt/current/vrun.sh /opt/current/app.py --port=%(process_num)s
stdout_logfile=/var/log/server/server.log
stderr_logfile=/var/log/server/server.err
numprocs = 6
numprocs_start = 7000

I've yet to find the "best" way to restart things, what I'll probably finally do is have Nginx have a "active" file which is updated letting HAProxy know that we're messing with configuration then wait a bit, swap things around, then re-enable everything. 我还没有找到重启事物的“最佳”方式,我可能最终会做的是让Nginx有一个“活动”文件更新,让HAProxy知道我们正在搞乱配置然后稍等一下,交换周围的事情,然后重新启用一切。

We're using Capistrano (we've got a backlog task to move to Fabric), but instead of dealing with removing *.pyc files we symlink /opt/current to the release identifier. 我们正在使用Capistrano(我们有一个积压任务转移到Fabric),但我们没有处理删除* .pyc文件,而是将符号链接/ opt / current添加到发布标识符。

I haven't deployed Tornado in production, but I've been playing with Gevent + Nginx and have been using Supervisord for process management - start/stop/restart, logging, monitoring - supervisorctl is very handy for this. 我没有在生产中部署Tornado,但我一直在玩Gevent + Nginx并且一直在使用Supervisord进行流程管理 - 启动/停止/重启,日志记录,监控 - supervisorctl非常方便。 Like I said, not a deployment solution, but maybe a tool worth using. 就像我说的,不是部署解决方案,但可能是值得使用的工具。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM