简体   繁体   English

使用Capistrano运行同步或异步任务

[英]Run simultaneous or asynchronous tasks with Capistrano

I have a few long-running restarts of processes in my deploy.rb like: 我在deploy.rb有一些长时间重启的进程,如:

  • rake assets:precompile
  • script/delayed_job restart
  • rake sunspot:solr:stop , rake sunspot:solr:start rake sunspot:solr:stoprake sunspot:solr:start

All of these processes have to occur, but not necessarily one after another. 所有这些过程都必须发生,但不一定是一个接一个。

I was wondering if I can run the assets:precompile and the delayed_job restart simultaneously, as they don't need to happen one after another, and I could speed up my deploy time by doing them asynchronously. 我想知道我是否可以运行assets:precompiledelayed_job restart同时delayed_job restart ,因为它们不需要一个接一个地发生,我可以通过异步执行来加快部署时间。

I've run some Google searches but I can't find anything about it. 我运行了一些谷歌搜索,但我找不到任何相关信息。

This is not a feature that capistrano supports. 这不是capistrano支持的功能。

I have been looking around for a solution and found something on the Capistrano google groups . 我一直在寻找解决方案,并在Capistrano谷歌团体上找到了一些东西。 The suggestion was to use Capistrano to run a ruby script that runs the jobs in parallel using Ruby's own threading support. 建议是使用Capistrano运行ruby脚本,使用Ruby自己的线程支持并行运行作业。

If you read the post one of the authors does ask why do these tasks need to run in parallel because you can introduce race conditions and other non-deterministic behaviour which can make the deployment process more brittle. 如果您阅读帖子,其中一位作者确实会问为什么这些任务需要并行运行,因为您可能会引入竞争条件和其他非确定性行为,从而使部署过程更加脆弱。

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

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