使用Capistrano部署仅限cron作业的应用程序?

时间:2013-02-24 10:47:20

标签: ruby deployment capistrano whenever

我有一个只作为cron作业运行的应用程序。 我正在使用whatever gem来维护和部署我的cron作业。

这是我目前的部署脚本。

require "bundler/capistrano"
require "whenever/capistrano"

set :application, "my-app"
set :domain, "example.com"
set :bundle_runner, "bundle exec"

# Git
set :scm, :git
set :repository, "git@bitbucket.org:username/my-app.rb.git"
set :branch, "master"

# Config
role :app, "example.com"
set :deploy_to,  "/opt/apps/#{application}"
set :deploy_via, :remote_cache
set :keep_releases, 5
set :git_enable_submodules, 1
set :git_shallow_clone, 1

# User
set :user, "webmaster"
set :use_sudo, false

# SSH
ssh_options[:paranoid] = false
ssh_options[:forward_agent] = true

set :bundle_cmd, "bundle"
set :bundle_without, [:test, :development]
set :bundle_flags,    "--deployment --without=development,test"

set :whenever_command, "#{bundle_cmd} exec whenever"

namespace :deploy do
  task :restart, roles: [:app] do
    whenever.update_crontab
  end
end

问题是我在部署期间遇到此错误。

* executing "cd -- /opt/apps/my-app/releases/20130224004202 && bbundle2 exec rake RAILS_ENV=production RAILS_GROUPS=assets assets:precompile && cp -- /opt/apps/my-app/shared/assets/manifest.yml /opt/apps/my-app/releases/20130224004202/assets_manifest.yml"
    servers: ["example.com"]
    [example.com] executing command
*** [err :: example.com] rake aborted!
*** [err :: example.com] No Rakefile found (looking for: rakefile, Rakefile, rakefile.rb, Rakefile.rb)
*** [err :: example.com] 
*** [err :: example.com] (See full trace by running task with --trace)
    command finished in 802ms
*** [deploy:update_code] rolling back
  * executing "rm -rf /opt/apps/my-app/releases/20130224004202; true"
    servers: ["example.com"]
    [example.com] executing command
    command finished in 111ms

看起来Capistrano认为这是一个rails应用程序,但事实并非如此。 有没有办法在运行cap deploy

时才执行以下操作
  • 从远程存储库下载源代码。
  • 更新current文件夹。
  • 使用随时更新crontabs。

0 个答案:

没有答案