我有一个仅作为 cron 作业运行的应用程序。我正在使用when 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。