This commit is contained in:
BoHung Chiu 2022-03-31 13:53:05 +08:00
parent 9cbf30c14a
commit 3d871aec8f
3 changed files with 12 additions and 4 deletions

View File

@ -20,6 +20,7 @@ namespace :create_site do
@site_construct = SiteConstruct.find(args.site_construct_id)
end
begin
org_creating = (@site_construct.status == "creating")
@site_construct.update(:status=>"creating")
@site_construct.update!(:infos=>[])
begin
@ -48,7 +49,7 @@ namespace :create_site do
end
server = SiteServer.where(:server_name => template_site.server_type).first
ls_out = exec_ssh_command_for_create(ssh, "ls #{@site_construct.full_site_path}/app").join("\n")
if ls_out.include?("No such")
if ls_out.include?("No such") || org_creating
if @site_construct.server_type == template_site.server_type
exec_ssh_command_for_create(ssh,"rsync -arv --delete --exclude={tmp/cache/,tmp/unicorn.sock,tmp/pids/*#{extra_exclude_path}} #{template_site.path}/#{template_site.get_site_name}/ #{args.path}/#{@site_construct.get_site_name}/",true)
else

View File

@ -132,11 +132,17 @@ namespace :create_site do
end
return outputs.join("\n")
end
def update_infos_for_exec(info,update_last=false)
def update_infos_for_exec(info,update_last=false,update_array=false)
return if @site_construct.nil?
info.encode!("UTF-8", :invalid => :replace, :undef => :replace, :replace => '')
if update_last && !@site_construct.infos.empty?
@site_construct.infos[-1] += info
@site_construct.infos[-1] += info.to_s
else
@site_construct.infos = @site_construct.infos.push(info)
if update_array
@site_construct.infos += info
else
@site_construct.infos.push(info.to_s)
end
end
@site_construct.save!
return @site_construct.infos

View File

@ -158,6 +158,7 @@ namespace :exec_commands do
end
def update_infos_for_exec(info,update_last=false,update_array=false)
return if @site_construct.nil?
info.encode!("UTF-8", :invalid => :replace, :undef => :replace, :replace => '')
if update_last && !@site_construct.infos.empty?
@site_construct.infos[-1] += info.to_s
else