Fix bug.
This commit is contained in:
parent
1668d44c7c
commit
481ff945a0
|
@ -70,9 +70,9 @@ class Admin::SitePanelController < OrbitAdminController
|
||||||
site_construct.user_id = current_user.id.to_s
|
site_construct.user_id = current_user.id.to_s
|
||||||
site_construct.status = "creating"
|
site_construct.status = "creating"
|
||||||
site_construct.save
|
site_construct.save
|
||||||
git_user = "chiu"
|
git_url = "http://ruling.digital/git"#"http://gitlab.tp.rulingcom.com/orbit_chiu1/orbit4-5.git"
|
||||||
git_password = "orbit_is_great_1"
|
git_template_url = "http://gitlab.tp.rulingcom.com/themes/default-theme.git"
|
||||||
git_url = "http://gitlab.tp.rulingcom.com/orbit_chiu1/orbit4-5.git"
|
git_extension_url = "http://gitlab.tp.rulingcom.com/core/default-modules.git"
|
||||||
site_server = SiteServer.where(:server_name=>site_construct.server_type).first
|
site_server = SiteServer.where(:server_name=>site_construct.server_type).first
|
||||||
ip = site_server.ip
|
ip = site_server.ip
|
||||||
user = site_server.account
|
user = site_server.account
|
||||||
|
@ -84,16 +84,16 @@ class Admin::SitePanelController < OrbitAdminController
|
||||||
path = site_construct.path
|
path = site_construct.path
|
||||||
site_construct_id = site_construct.id.to_s
|
site_construct_id = site_construct.id.to_s
|
||||||
Thread.new do
|
Thread.new do
|
||||||
system("rake create_site:create_site[#{git_user},#{git_password},#{git_url},#{ip},#{user},#{password},#{site_name},#{domain_name},#{port},#{db_name},#{path},#{site_construct_id}]")
|
system("rake create_site:create_site['#{git_template_url}','#{git_extension_url}','#{git_url}','#{ip}','#{user}','#{password}','#{site_name}','#{domain_name}','#{port}','#{db_name}','#{path}','#{site_construct_id}']")
|
||||||
end
|
end
|
||||||
redirect_to "#{admin_site_panel_sites_list_path}?id=#{site_construct_id}"
|
redirect_to "#{admin_site_panel_sites_list_path}?id=#{site_construct_id}"
|
||||||
end
|
end
|
||||||
def create_site
|
def create_site
|
||||||
site_construct = SiteConstruct.find(params[:id])
|
site_construct = SiteConstruct.find(params[:id])
|
||||||
site_construct.user_id = current_user.id.to_s
|
site_construct.user_id = current_user.id.to_s
|
||||||
git_user = "chiu"
|
git_url = "http://ruling.digital/git"#"http://gitlab.tp.rulingcom.com/orbit_chiu1/orbit4-5.git"
|
||||||
git_password = "orbit_is_great_1"
|
git_template_url = "http://gitlab.tp.rulingcom.com/themes/default-theme.git"
|
||||||
git_url = "http://gitlab.tp.rulingcom.com/orbit_chiu1/orbit4-5.git"
|
git_extension_url = "http://gitlab.tp.rulingcom.com/core/default-modules.git"
|
||||||
site_server = SiteServer.where(:server_name=>site_construct.server_type).first
|
site_server = SiteServer.where(:server_name=>site_construct.server_type).first
|
||||||
ip = site_server.ip
|
ip = site_server.ip
|
||||||
user = site_server.account
|
user = site_server.account
|
||||||
|
@ -105,7 +105,7 @@ class Admin::SitePanelController < OrbitAdminController
|
||||||
path = site_construct.path
|
path = site_construct.path
|
||||||
site_construct_id = params[:id]
|
site_construct_id = params[:id]
|
||||||
Thread.new do
|
Thread.new do
|
||||||
system("rake create_site:create_site['#{git_user}','#{git_password}','#{git_url}','#{ip}','#{user}','#{password}','#{site_name}','#{domain_name}','#{port}','#{db_name}','#{path}','#{site_construct_id}']")
|
system("rake create_site:create_site['#{git_template_url}','#{git_extension_url}','#{git_url}','#{ip}','#{user}','#{password}','#{site_name}','#{domain_name}','#{port}','#{db_name}','#{path}','#{site_construct_id}']")
|
||||||
end
|
end
|
||||||
render :json =>{"success"=>true}
|
render :json =>{"success"=>true}
|
||||||
end
|
end
|
||||||
|
|
|
@ -161,6 +161,7 @@
|
||||||
})
|
})
|
||||||
$("#site_construct_site_type").val("School");
|
$("#site_construct_site_type").val("School");
|
||||||
$("form.main-forms").submit(function(){
|
$("form.main-forms").submit(function(){
|
||||||
|
$("#domain_name").removeAttr('disabled');
|
||||||
$("#path").removeAttr("disabled");
|
$("#path").removeAttr("disabled");
|
||||||
var type = $("#site_construct_site_type").val();
|
var type = $("#site_construct_site_type").val();
|
||||||
type = (type == "School" ? "school_sites" : "orbit_sites" );
|
type = (type == "School" ? "school_sites" : "orbit_sites" );
|
||||||
|
|
|
@ -2,7 +2,7 @@ require 'net/ssh'
|
||||||
require 'pathname'
|
require 'pathname'
|
||||||
namespace :create_site do
|
namespace :create_site do
|
||||||
desc "Create Site Script"
|
desc "Create Site Script"
|
||||||
task :create_site,[:git_user,:git_password,:git_url,:ip,:user,:password,:site_name,:domain_name,:port,:db_name,:path,:site_construct_id] => :environment do |task,args|
|
task :create_site,[:git_template_url,:git_extension_url,:git_url,:ip,:user,:password,:site_name,:domain_name,:port,:db_name,:path,:site_construct_id] => :environment do |task,args|
|
||||||
@password = args.password
|
@password = args.password
|
||||||
puts args
|
puts args
|
||||||
if args.site_construct_id.blank?
|
if args.site_construct_id.blank?
|
||||||
|
@ -62,7 +62,10 @@ namespace :create_site do
|
||||||
dir = dir.dirname
|
dir = dir.dirname
|
||||||
end
|
end
|
||||||
update_infos("cloning orbit4-5 from #{args.git_url} to #{args.path}/#{args.site_name}")
|
update_infos("cloning orbit4-5 from #{args.git_url} to #{args.path}/#{args.site_name}")
|
||||||
exec_ssh_command_by_sudo_for_create(ssh,"git clone #{args.git_url.gsub("http://","http://#{args.git_user+':'+args.git_password+'@'}").gsub("https://","https://#{args.git_user+':'+args.git_password+'@'}")} #{args.path}/#{args.site_name}")
|
exec_ssh_command_by_sudo_for_create(ssh,"git clone #{args.git_url} #{args.path}/#{args.site_name}")
|
||||||
|
exec_ssh_command_by_sudo_for_create(ssh,"bash -l -c 'cd #{args.path}/#{args.site_name} && git submodule add #{args.git_template_url} app/templates/default-theme'")
|
||||||
|
exec_ssh_command_by_sudo_for_create(ssh,"bash -l -c 'cd #{args.path}/#{args.site_name} && git submodule add #{args.git_extension_url} modules'")
|
||||||
|
ssh.exec!("bash -l -c 'cd #{args.path}/#{args.site_name} && ln -s modules/* .'")
|
||||||
exec_ssh_command_by_sudo_for_create(ssh,"sudo -p 'sudo password:' chown #{args.user}:#{args.user} #{args.path}/#{args.site_name} -R")
|
exec_ssh_command_by_sudo_for_create(ssh,"sudo -p 'sudo password:' chown #{args.user}:#{args.user} #{args.path}/#{args.site_name} -R")
|
||||||
exec_ssh_command_by_sudo_for_create(ssh,"sudo -p 'sudo password:' chmod 777 #{args.path}/#{args.site_name} -R")
|
exec_ssh_command_by_sudo_for_create(ssh,"sudo -p 'sudo password:' chmod 777 #{args.path}/#{args.site_name} -R")
|
||||||
db_setting_text = ssh.exec!("cat #{args.path}/#{args.site_name}/config/mongoid.yml")
|
db_setting_text = ssh.exec!("cat #{args.path}/#{args.site_name}/config/mongoid.yml")
|
||||||
|
@ -82,11 +85,11 @@ namespace :create_site do
|
||||||
else
|
else
|
||||||
bundle_dir = gemdir.gsub("\n","") + '/bin/bundle'
|
bundle_dir = gemdir.gsub("\n","") + '/bin/bundle'
|
||||||
update_infos("execing bundle install...")
|
update_infos("execing bundle install...")
|
||||||
exec_ssh_command_by_sudo_for_create(ssh,"bash -l -c 'cd #{args.path}/#{args.site_name}\n#{bundle_dir} install'",true)
|
exec_ssh_command_by_sudo_for_create(ssh,"bash -l -c 'cd #{args.path}/#{args.site_name}\nbundle install'",true)
|
||||||
exec_ssh_command_by_sudo_for_create(ssh,"bash -l -c 'cd #{args.path}/#{args.site_name}\n#{bundle_dir} install'")
|
exec_ssh_command_by_sudo_for_create(ssh,"bash -l -c 'cd #{args.path}/#{args.site_name}\nbundle install'")
|
||||||
update_infos("finish execing bundle install")
|
update_infos("finish execing bundle install")
|
||||||
update_infos("starting #{args.site_name} web server to development")
|
update_infos("starting #{args.site_name} web server to development")
|
||||||
outputs = exec_ssh_command_by_sudo_for_create(ssh,"bash -l -c 'cd #{args.path}/#{args.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\n#{bundle_dir} exec unicorn_rails -c config/unicorn.rb -D -E development\n'")
|
outputs = exec_ssh_command_by_sudo_for_create(ssh,"bash -l -c 'cd #{args.path}/#{args.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 development\n'")
|
||||||
if outputs.include? "not writable"
|
if outputs.include? "not writable"
|
||||||
exec_ssh_command_by_sudo_for_create(ssh,"sudo -p 'sudo password:' chown #{args.user}:#{args.user} #{args.path}/#{args.site_name} -R")
|
exec_ssh_command_by_sudo_for_create(ssh,"sudo -p 'sudo password:' chown #{args.user}:#{args.user} #{args.path}/#{args.site_name} -R")
|
||||||
exec_ssh_command_by_sudo_for_create(ssh,"sudo -p 'sudo password:' chmod 777 #{args.path}/#{args.site_name} -R")
|
exec_ssh_command_by_sudo_for_create(ssh,"sudo -p 'sudo password:' chmod 777 #{args.path}/#{args.site_name} -R")
|
||||||
|
|
Loading…
Reference in New Issue