This commit is contained in:
BoHung Chiu 2023-07-19 17:22:39 +08:00
parent 4f6f07280a
commit d3328cf9b4
4 changed files with 17 additions and 17 deletions

View File

@ -317,6 +317,7 @@ class Admin::SitePanelController < OrbitAdminController
db_name = site_construct.db_name
path = site_construct.path
site_construct_id = params[:id]
site_construct.update(:status => "creating")
if site_construct.copy_id
Thread.new do
system("bundle exec rake create_site:copy_site['#{ip}','#{server_port}','#{user}','#{password}','#{site_name}','#{domain_name}','#{port}','#{db_name}','#{path}','#{site_construct_id}','#{site_construct.copy_id}',#{site_construct.only_copy_installed_module}]")
@ -331,6 +332,8 @@ class Admin::SitePanelController < OrbitAdminController
def edit_site
case params[:type]
when 'delete'
@site_construct = SiteConstruct.find(params[:id])
@site_construct.update(:status => "deleting")
Thread.new do
system("bundle exec rake create_site:delete_site[#{params[:id]}]")
end

View File

@ -226,12 +226,8 @@
"</div>");
}else{
$("#info_texts").html("Do you really want to "+_this.attr('title')+".");
if($('#confirm_input').length == 0){
$('#info_texts').after("<input id=\"confirm_input\"/ placeholder=\"<%= t('client_management.please_input_confirm_recreate') %>\" style=\"width: 17em;\">");
}else{
$('#confirm_input').css('display','block');
$('#confirm_input').val('');
}
$('#confirm_input').remove();
$('#info_texts').after("<input id=\"confirm_input\"/ placeholder=\"<%= t('client_management.please_input_confirm_recreate') %>\" style=\"width: 17em;\">");
}
$( "#dialog-confirm" ).dialog({
resizable: true,
@ -285,12 +281,8 @@
"</div>");
}else{
$("#info_texts").html("Do you really want to "+$(this).attr('title')+".");
if($('#confirm_input').length == 0){
$('#info_texts').after("<input id=\"confirm_input\"/ placeholder=\"<%= t('client_management.please_input_confirm_delete') %>\" style=\"width: 17em;\">");
}else{
$('#confirm_input').css('display','block');
$('#confirm_input').val('');
}
$('#confirm_input').remove();
$('#info_texts').after("<input id=\"confirm_input\"/ placeholder=\"<%= t('client_management.please_input_confirm_delete') %>\" style=\"width: 17em;\">");
}
$( "#dialog-confirm" ).dialog({
resizable: true,

View File

@ -48,9 +48,8 @@ namespace :create_site do
extra_exclude_path = ",public/uploads/"
end
server = SiteServer.where(:server_name => template_site.server_type).first
update_infos("Copying site's files for #{args.site_name}!")
ls_out = exec_ssh_command_for_copy(ssh, "ls #{@site_construct.full_site_path}/app", false).join("\n")
if ls_out.include?("No such") || org_creating
ls_out = exec_ssh_command_for_copy(ssh, "if [ ! -d \"#{@site_construct.full_site_path}/app\" ]; then echo 'No such file or directory: #{@site_construct.full_site_path}/app'; fi", false).join("\n")
if ls_out.include?("No such file or directory") || org_creating
if @site_construct.server_type == template_site.server_type
exec_ssh_command_for_copy(ssh,"rsync -ar --info=progress2 --no-inc-recursive --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
@ -141,9 +140,12 @@ namespace :create_site do
end
def exec_ssh_command_for_copy(session,command,update_outputs=false)
outputs = []
if update_outputs
update_infos_for_exec("")
end
session.open_channel do |channel|
channel.request_pty do |channel, success|
channel.exec("LANG=en.UTF8 #{command}") do |ch, success|
channel.exec("LANG=en.UTF8 && #{command}") do |ch, success|
abort "could not execute command: #{command}" unless success
channel.on_data do |ch, data|
data_str = data.to_s

View File

@ -110,9 +110,12 @@ namespace :create_site do
end
def exec_ssh_command_for_create(session,command,update_outputs=false)
outputs = []
if update_outputs
update_infos_for_exec("")
end
session.open_channel do |channel|
channel.request_pty do |channel, success|
channel.exec("LANG=en.UTF8 #{command}") do |ch, success|
channel.exec("LANG=en.UTF8 && #{command}") do |ch, success|
abort "could not execute command: #{command}" unless success
channel.on_data do |ch, data|
data_str = data.to_s