我在deploy.rb
中有这个,但我不知道如何在部署服务器中运行此命令:
rake db:production RAILS_ENV=production
我所拥有的不起作用。我等你的答案。如果你知道如何在部署完成时启动独角兽。
# Define where can Capistrano access the source repository
# set :repo_url, 'https://github.com/myuser/myapp.git'
set :scm, :git
set :repo_url, 'https://github.com/myuser/myapp.git'
# Define where to put your application code
set :deploy_to, "/home/deployer/apps/myapp"
set :pty, true
set :format, :pretty
set :rails_env, "production"
namespace :rake do
desc "Invoke rake task"
task :invoke do
run "cd #{deploy_to}/current"
run "bundle exec rake #{ENV['task']} RAILS_ENV=#{rails_env}"
end
end
答案 0 :(得分:0)
你可以这样做:
%w[start stop restart].each do |command|
desc "#{command} unicorn server"
task command, roles: :app, except: {no_release: true} do
run "/etc/init.d/unicorn_#{application} #{command}"
end
end
并考虑你的任务:
task :your_task, :roles => :app do
run "cd #{release_path}; bundle exec rake db:production RAILS_ENV=#{rails_env}"
end