我正在尝试使用Mina将我的应用部署到我的服务器,我需要自动重启服务器。但不幸的是,这不起作用,我不知道为什么。这是我正在尝试的:
require 'mina/bundler'
require 'mina/rvm'
require 'mina/rails'
require 'mina/git'
...
set :unicorn_conf, "#{shared_path}/config/unicorn.rb"
set :unicorn_pid, "#{deploy_to}/current/tmp/pids/unicorn.pid"
...
task :environment do
invoke :'rvm:use[ruby-2.2.3]'
end
task deploy: :environment do
deploy do
# Put things that prepare the empty release folder here.
# Commands queued here will be run on a new release directory.
invoke :'git:clone'
invoke :'deploy:link_shared_paths'
invoke :'bundle:install'
invoke :'rails:db_migrate'
invoke :'rails:assets_precompile'
invoke :restart_server
end
end
task :restart_server do
if File.exists? unicorn_pid
queue 'kill `cat #{unicorn_pid}`'
end
queue 'bundle exec unicorn -c #{deploy_to}/#{unicorn_conf} -E production -D'
puts "bundle exec unicorn -c #{deploy_to}/#{:unicorn_conf} -E production -D"
end
这是最后一个puts
语句,我只是为了调试而打印出我想要的字符串。但我仍然有这个错误:
/home/webuser/tmpcms/tmp/build-145333668721611/vendor/bundle/ruby/2.2.0/gems/unicorn-5.0.1/bin/unicorn:110:in `block in <top (required)>': missing argument: -c (OptionParser::MissingArgument)
from /home/webuser/tmpcms/tmp/build-145333668721611/vendor/bundle/ruby/2.2.0/gems/unicorn-5.0.1/bin/unicorn:10:in `new'
from /home/webuser/tmpcms/tmp/build-145333668721611/vendor/bundle/ruby/2.2.0/gems/unicorn-5.0.1/bin/unicorn:10:in `<top (required)>'
from /home/webuser/tmpcms/tmp/build-145333668721611/vendor/bundle/ruby/2.2.0/bin/unicorn:23:in `load'
from /home/webuser/tmpcms/tmp/build-145333668721611/vendor/bundle/ruby/2.2.0/bin/unicorn:23:in `<main>'
! bash: line 209: log: command not found
! ERROR: Deploy failed.
我不知道是什么原因造成的,你能帮帮我吗?
UPD:它似乎是变量替换和fetch
函数,但我仍然无法理解错误。这是我测试过的:
task :restart_server => :environment do
if File.exists? unicorn_pid
queue 'kill `cat #{unicorn_pid}`'
end
queue 'cd /home/webuser/tmpcms/current; pwd; bundle exec unicorn -c #{deploy_to}/#{unicorn_conf} -E production -D'
end
bundle exec
部分不起作用,它不会执行它并打印Connection closed
。如果我将cd
命令中的路径替换为cd #{deploy_to}
或cd #{fetch(:deploy_to)}
答案 0 :(得分:0)
哦,我的,答案很简单。 我忘记了我使用单引号而不是双引号,并且变量没有被替换。 用双引号替换单引号就解决了它。