Fix bug.
This commit is contained in:
parent
04623bcca1
commit
b93bf910d2
|
@ -35,7 +35,7 @@ namespace :exec_commands do
|
||||||
@command_trans = {}
|
@command_trans = {}
|
||||||
@command_relations = {"upgrade_site"=>'git fetch origin && rails runner "a=Admin::SitesController.new;a.git_reset(%w(origin)[0],%w(update)[0]);while(1) do (Multithread.where(key: %w(update_manager)[0],status: %w(finish)[0]).count!=0 ? break : nil) end;sleep(5)"',
|
@command_relations = {"upgrade_site"=>'git fetch origin && rails runner "a=Admin::SitesController.new;a.git_reset(%w(origin)[0],%w(update)[0]);while(1) do (Multithread.where(key: %w(update_manager)[0],status: %w(finish)[0]).count!=0 ? break : nil) end;sleep(5)"',
|
||||||
"bundle_update"=>"bundle update && kill -s USR2 `cat tmp/pids/unicorn.pid`",
|
"bundle_update"=>"bundle update && kill -s USR2 `cat tmp/pids/unicorn.pid`",
|
||||||
"restart_site"=>"kill -s TERM `fuser tmp/pids/unicorn.sock tmp/sockets/unicorn.sock tmp/unicorn.sock`;bundle exec unicorn_rails -c config/unicorn.rb -D -E {{rails_env}}",
|
"restart_site"=>"kill -s TERM `fuser tmp/pids/unicorn.sock tmp/sockets/unicorn.sock tmp/unicorn.sock 2>/dev/null`; rvm use `cat .ruby-version`; bundle exec unicorn_rails -c config/unicorn.rb -D -E {{rails_env}}",
|
||||||
"get_template"=>"mongo --eval 'db.sites.find().pretty()[0][\"template\"]' {{db_name}} --quiet"}
|
"get_template"=>"mongo --eval 'db.sites.find().pretty()[0][\"template\"]' {{db_name}} --quiet"}
|
||||||
@preserve_output = ["get_template"]
|
@preserve_output = ["get_template"]
|
||||||
@command_relations.each do |k,v|
|
@command_relations.each do |k,v|
|
||||||
|
@ -43,7 +43,7 @@ namespace :exec_commands do
|
||||||
end
|
end
|
||||||
rails_envs = ["production", "development"]
|
rails_envs = ["production", "development"]
|
||||||
rails_envs.each do |env|
|
rails_envs.each do |env|
|
||||||
@command_relations["start_site_in_env,#{env}"] = "kill -s TERM `fuser tmp/pids/unicorn.sock tmp/sockets/unicorn.sock tmp/unicorn.sock`;bundle exec unicorn_rails -c config/unicorn.rb -D -E #{env}"
|
@command_relations["start_site_in_env,#{env}"] = "kill -s TERM `fuser tmp/pids/unicorn.sock tmp/sockets/unicorn.sock tmp/unicorn.sock 2>/dev/null`; rvm use `cat .ruby-version`; bundle exec unicorn_rails -c config/unicorn.rb -D -E #{env}"
|
||||||
@command_relations["start_site_in_env\\,#{env}"] = @command_relations["start_site_in_env,#{env}"]
|
@command_relations["start_site_in_env\\,#{env}"] = @command_relations["start_site_in_env,#{env}"]
|
||||||
@command_trans["start_site_in_env,#{env}"] = I18n.t("client_management.start_site_in_env",{:env=>env})
|
@command_trans["start_site_in_env,#{env}"] = I18n.t("client_management.start_site_in_env",{:env=>env})
|
||||||
@command_trans["start_site_in_env\\,#{env}"] = @command_trans["start_site_in_env,#{env}"]
|
@command_trans["start_site_in_env\\,#{env}"] = @command_trans["start_site_in_env,#{env}"]
|
||||||
|
@ -74,7 +74,7 @@ namespace :exec_commands do
|
||||||
@site_construct.update!(:infos=>[]) rescue nil
|
@site_construct.update!(:infos=>[]) rescue nil
|
||||||
if args.type == 'close_site'
|
if args.type == 'close_site'
|
||||||
exec_ssh_command_by_sudo_and_see_output(ssh,"chmod 777 #{@site_construct.path}/#{@site_construct.site_name} -R",false)
|
exec_ssh_command_by_sudo_and_see_output(ssh,"chmod 777 #{@site_construct.path}/#{@site_construct.site_name} -R",false)
|
||||||
exec_ssh_command_by_sudo_and_see_output(ssh,"bash -l -c 'kill -s TERM `fuser #{@site_construct.path}/#{@site_construct.site_name}/tmp/unicorn.sock`'",false)
|
exec_ssh_command_by_sudo_and_see_output(ssh,"bash -l -c 'kill -s TERM `fuser #{@site_construct.path}/#{@site_construct.site_name}/tmp/unicorn.sock 2>/dev/null`'",false)
|
||||||
update_infos_for_exec("Finish closing #{@site_construct.site_name}")
|
update_infos_for_exec("Finish closing #{@site_construct.site_name}")
|
||||||
@site_construct.update(:status =>"closed")
|
@site_construct.update(:status =>"closed")
|
||||||
elsif args.type == 'open_site'
|
elsif args.type == 'open_site'
|
||||||
|
@ -97,17 +97,17 @@ namespace :exec_commands do
|
||||||
@site_construct.update(:rails_env=>rails_env)
|
@site_construct.update(:rails_env=>rails_env)
|
||||||
update_infos_for_exec("Starting site to #{rails_env}")
|
update_infos_for_exec("Starting site to #{rails_env}")
|
||||||
outputs = exec_ssh_command_by_sudo_and_see_output(ssh,"sudo -p 'sudo password:' chmod 777 #{@site_construct.path}/#{@site_construct.site_name} -R",false)
|
outputs = exec_ssh_command_by_sudo_and_see_output(ssh,"sudo -p 'sudo password:' chmod 777 #{@site_construct.path}/#{@site_construct.site_name} -R",false)
|
||||||
output = exec_ssh_command_by_sudo_and_see_output(ssh,"bash -l -c 'cd #{@site_construct.path}/#{@site_construct.site_name}\nkill -s TERM `fuser tmp/unicorn.sock`\nsudo -p \"sudo password:\" kill -s TERM `sudo -p \"sudo password:\" fuser tmp/unicorn.sock`\nsudo -p \"sudo password:\" rm -f tmp/pids/unicorn.pid\nbundle exec unicorn_rails -c config/unicorn.rb -D -E #{rails_env}\n'",false)
|
output = exec_ssh_command_by_sudo_and_see_output(ssh,"bash -l -c 'cd #{@site_construct.path}/#{@site_construct.site_name}\nkill -s TERM `fuser tmp/unicorn.sock 2>/dev/null`\nsudo -p \"sudo password:\" kill -s TERM `sudo -p \"sudo password:\" fuser tmp/unicorn.sock 2>/dev/null`\nsudo -p \"sudo password:\" rm -f tmp/pids/unicorn.pid\n rvm use `cat .ruby-version`\nbundle exec unicorn_rails -c config/unicorn.rb -D -E #{rails_env}\n'",false)
|
||||||
if output.include? "bundle install"
|
if output.include? "bundle install"
|
||||||
update_infos_for_exec("Not yet bundle install")
|
update_infos_for_exec("Not yet bundle install")
|
||||||
outputs = exec_ssh_command_by_sudo_and_see_output(ssh,"bash -l -c 'cd #{@site_construct.path}/#{@site_construct.site_name};bundle install'")
|
outputs = exec_ssh_command_by_sudo_and_see_output(ssh,"bash -l -c 'cd #{@site_construct.path}/#{@site_construct.site_name}; rvm use `cat .ruby-version`; bundle install'")
|
||||||
if outputs.join("\n").include? "Username for"
|
if outputs.join("\n").include? "Username for"
|
||||||
update_infos_for_exec("Cannot finish bundle install.")
|
update_infos_for_exec("Cannot finish bundle install.")
|
||||||
update_infos_for_exec("This site include an private git project.")
|
update_infos_for_exec("This site include an private git project.")
|
||||||
@site_construct.update(:status =>"error")
|
@site_construct.update(:status =>"error")
|
||||||
break
|
break
|
||||||
else
|
else
|
||||||
exec_ssh_command_by_sudo_and_see_output(ssh,"bundle exec unicorn_rails -c config/unicorn.rb -D -E #{rails_env}",false)
|
exec_ssh_command_by_sudo_and_see_output(ssh,"bash -l -c 'cd #{@site_construct.path}/#{@site_construct.site_name}; rvm use `cat .ruby-version`; bundle exec unicorn_rails -c config/unicorn.rb -D -E #{rails_env}'",false)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
update_infos_for_exec("Finish starting #{@site_construct.site_name}")
|
update_infos_for_exec("Finish starting #{@site_construct.site_name}")
|
||||||
|
|
Loading…
Reference in New Issue