繁体   English   中英

如何使Capistrano 3运行耙并启动独角兽?

[英]How to make capistrano 3 run rake and start unicorn?

我的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

您可以执行以下操作:

%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

暂无
暂无

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

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