"missing argument -c" 当通过 Mina 重启 Unicorn 时
"missing argument -c" when restarting Unicorn via Mina
我正在尝试使用 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)}
天哪,答案太简单了。
我忘记了我使用的是单引号而不是双引号,并且没有在需要时替换变量。
只需将单引号替换为双引号即可解决。
我正在尝试使用 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)}
天哪,答案太简单了。 我忘记了我使用的是单引号而不是双引号,并且没有在需要时替换变量。 只需将单引号替换为双引号即可解决。