fix error
This commit is contained in:
parent
2d55dd83c3
commit
b7353a5acb
|
@ -4,212 +4,215 @@ $:.push File.expand_path("../lib", __FILE__)
|
||||||
# Maintain your gem's version:
|
# Maintain your gem's version:
|
||||||
require "announcement/version"
|
require "announcement/version"
|
||||||
require 'json'
|
require 'json'
|
||||||
env_pwd = ENV['PWD']
|
bundle_update_flag = ARGV[0]=='update' || ARGV[0]=='install'
|
||||||
app_path = File.expand_path(__dir__)
|
if bundle_update_flag
|
||||||
template_path = env_pwd + '/app/templates'
|
env_pwd = ENV['PWD']
|
||||||
all_template = Dir.glob(template_path+'/*/')
|
app_path = File.expand_path(__dir__)
|
||||||
puts 'editing files for sassc'
|
template_path = env_pwd + '/app/templates'
|
||||||
new_gemfile_text = File.read(app_path+'/temp_file/Gemfile')
|
all_template = Dir.glob(template_path+'/*/')
|
||||||
old_gemfile_text = File.read(env_pwd+'/Gemfile')
|
puts 'editing files for sassc'
|
||||||
check_texts = ['@import "../../bootstrap/variables";',".response-content {\n justify-self: auto;\n}\n"]
|
new_gemfile_text = File.read(app_path+'/temp_file/Gemfile')
|
||||||
git_url = Bundler.with_clean_env{%x[cd '#{env_pwd}' && git config --get remote.origin.url].split("\n")[0]}
|
old_gemfile_text = File.read(env_pwd+'/Gemfile')
|
||||||
git_remote = Bundler.with_clean_env{%x[cd '#{env_pwd}' && git remote].split("\n")[0]}
|
check_texts = ['@import "../../bootstrap/variables";',".response-content {\n justify-self: auto;\n}\n"]
|
||||||
if git_url != 'http://ruling.digital/git'
|
git_url = Bundler.with_clean_env{%x[cd '#{env_pwd}' && git config --get remote.origin.url].split("\n")[0]}
|
||||||
puts 'changing remote url'
|
git_remote = Bundler.with_clean_env{%x[cd '#{env_pwd}' && git remote].split("\n")[0]}
|
||||||
Bundler.with_clean_env{system("cd #{env_pwd} && git remote set-url #{git_remote} http://ruling.digital/git")}
|
if git_url != 'http://ruling.digital/git'
|
||||||
end
|
puts 'changing remote url'
|
||||||
default_announcement_widget_info = JSON.parse(File.read("#{app_path}/modules/announcement/info.json"))["widgets"].sort_by{|h| h["filename"].to_i} rescue []
|
Bundler.with_clean_env{system("cd #{env_pwd} && git remote set-url #{git_remote} http://ruling.digital/git")}
|
||||||
all_template.each do |folder|
|
end
|
||||||
if !folder.include?('mobile')
|
default_announcement_widget_info = JSON.parse(File.read("#{app_path}/modules/announcement/info.json"))["widgets"].sort_by{|h| h["filename"].to_i} rescue []
|
||||||
begin
|
all_template.each do |folder|
|
||||||
if folder.split('/')[-1] != 'mobile'
|
if !folder.include?('mobile')
|
||||||
unity_text = File.open(folder+'assets/stylesheets/template/base/_unity.scss','r:UTF-8') do |f|
|
|
||||||
f.read
|
|
||||||
end rescue ''
|
|
||||||
if unity_text.split(/\n/).join.strip.empty?
|
|
||||||
File.open(folder+'assets/stylesheets/template/base/_unity.scss', 'a') do |file|
|
|
||||||
file.puts "@charset \"utf-8\";\n\n@import \"variables\";\n\n// Title\n.unity-title {\n margin: 0.5em 0;\n line-height: 1.5;\n font-family: $main-font;\n font-size: $font-h1;\n\n .layout-footer & {\n margin-bottom: 10px;\n border-bottom: none;\n\n span {\n display: inline;\n margin-bottom: 0;\n border-bottom: none;\n }\n }\n}\n\n.status {\n font-family: $main-font;\n font-size: 0.75rem;\n}\n\n.status-top {\n background-color: $theme-color-second;\n}\n\n.status-hot {\n background-color: $theme-color-third;\n}\n\n.status-source {\n background-color: $theme-color-main;\n\n a {\n color: $theme-white;\n }\n}\n"
|
|
||||||
end
|
|
||||||
end
|
|
||||||
filename = folder+'assets/stylesheets/template/base/_variables.scss'
|
|
||||||
texts = File.open(filename,'r:UTF-8') do |f|
|
|
||||||
f.read
|
|
||||||
end.force_encoding('UTF-8')
|
|
||||||
s1 = texts.scan(/{|}/)
|
|
||||||
if s1.count % 2 != 0
|
|
||||||
i = texts.rindex(s1[-1])
|
|
||||||
texts[i] = ""
|
|
||||||
end
|
|
||||||
regex_pattern = /.response-content {\n justify-self: auto;\n}|.response-content {\n position: static;\n}|.response-content {\n position: relative;\n}/m #|.response-content[^{]*{[^}]*@media[^{]*{[^{]*}[^{]*@media[^{]*{[^{]*}[^}]*}[^}]*}
|
|
||||||
if !texts.include? "$font-h1:"
|
|
||||||
texts = "$font-h1: 1.5rem;\n$font-h2: 1.35rem;\n$font-h3: 1.2rem;\n$font-h4: 1.1rem;\n$font-h5: 1rem;\n$font-h6: 0.9rem;\n\n" + texts
|
|
||||||
end
|
|
||||||
if !texts.include? "$main-font:"
|
|
||||||
texts = "$main-font: Arial, \"微軟正黑體\", \"Helvetica Neue\", Helvetica, sans-serif;\n" + texts
|
|
||||||
end
|
|
||||||
if !texts.include? "$theme-white"
|
|
||||||
texts = "$theme-white: #fff;\n" + texts
|
|
||||||
end
|
|
||||||
File.open(filename,'w') do |f|
|
|
||||||
f.write texts
|
|
||||||
end
|
|
||||||
tp_text = File.read(folder+'assets/stylesheets/template/template.scss').force_encoding('UTF-8') rescue ''
|
|
||||||
tp_last_text = tp_text
|
|
||||||
tp_text.scan(/@import.*http.*;/).each do |pat|
|
|
||||||
if pat.scan(/@import\W+url/).count==0
|
|
||||||
pat1 = pat.sub(/@import\W/,"@import url(")
|
|
||||||
pat1 = pat1.sub(/;/,");")
|
|
||||||
tp_last_text = tp_last_text.sub(pat,pat1)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
if tp_last_text != tp_text
|
|
||||||
File.open(folder+'assets/stylesheets/template/template.scss','w') do |f|
|
|
||||||
f.write tp_last_text
|
|
||||||
end
|
|
||||||
end
|
|
||||||
if texts.split(regex_pattern).count >= 1
|
|
||||||
auto_save_text = texts.scan(regex_pattern).join('')
|
|
||||||
File.open(folder+'assets/stylesheets/template/base/_autobackup.bak', 'a') do |file|
|
|
||||||
file.puts auto_save_text
|
|
||||||
end
|
|
||||||
File.open(filename, 'w') do |file|
|
|
||||||
file.write (texts.split(regex_pattern).join('') + check_texts[1])
|
|
||||||
end
|
|
||||||
else
|
|
||||||
check_texts.each do |check_text|
|
|
||||||
if !texts.include?(check_text)
|
|
||||||
puts "editing #{folder}assets/stylesheets/template/base/_variables.scss"
|
|
||||||
texts = texts + check_text
|
|
||||||
File.open(filename, 'w') do |file|
|
|
||||||
file.write(texts)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
rescue => e
|
|
||||||
puts "not found #{folder}assets/stylesheets/template/base/_variables.scss"
|
|
||||||
end
|
|
||||||
begin
|
|
||||||
puts "updating announcement show page"
|
|
||||||
Bundler.with_clean_env{%x[cp -f #{app_path}/modules/announcement/show.html.erb #{folder}modules/announcement/show.html.erb]}
|
|
||||||
rescue
|
|
||||||
puts "There has some error in updating announcement show page"
|
|
||||||
end
|
|
||||||
info_json_file = "#{folder}modules/announcement/info.json"
|
|
||||||
if File.exist?(info_json_file)
|
|
||||||
begin
|
begin
|
||||||
file_text = File.read(info_json_file) rescue ""
|
if folder.split('/')[-1] != 'mobile'
|
||||||
encode_file_text = file_text.encode("UTF-8", "UTF-8", invalid: :replace, replace: "???")
|
unity_text = File.open(folder+'assets/stylesheets/template/base/_unity.scss','r:UTF-8') do |f|
|
||||||
next if (encode_file_text.include?("???") rescue true)
|
f.read
|
||||||
info = JSON.parse(encode_file_text) rescue {}
|
end rescue ''
|
||||||
flag = (info.count != 0 rescue false)
|
if unity_text.split(/\n/).join.strip.empty?
|
||||||
if flag
|
File.open(folder+'assets/stylesheets/template/base/_unity.scss', 'a') do |file|
|
||||||
puts "Checking announcement widgets"
|
file.puts "@charset \"utf-8\";\n\n@import \"variables\";\n\n// Title\n.unity-title {\n margin: 0.5em 0;\n line-height: 1.5;\n font-family: $main-font;\n font-size: $font-h1;\n\n .layout-footer & {\n margin-bottom: 10px;\n border-bottom: none;\n\n span {\n display: inline;\n margin-bottom: 0;\n border-bottom: none;\n }\n }\n}\n\n.status {\n font-family: $main-font;\n font-size: 0.75rem;\n}\n\n.status-top {\n background-color: $theme-color-second;\n}\n\n.status-hot {\n background-color: $theme-color-third;\n}\n\n.status-source {\n background-color: $theme-color-main;\n\n a {\n color: $theme-white;\n }\n}\n"
|
||||||
widget_info = info["widgets"].sort_by{|h| h["filename"].to_i} rescue []
|
|
||||||
update_flag = false
|
|
||||||
last_index = widget_info[-1]["filename"].match(/\d+/)[0].to_i rescue nil
|
|
||||||
if !last_index.nil?
|
|
||||||
default_announcement_widget_info.each do |h|
|
|
||||||
name_without_index = h["name"]["zh_tw"].sub(/\d+/,'')
|
|
||||||
if (widget_info.select{|hh| hh["name"]["zh_tw"].include?(name_without_index)}.count == 0)
|
|
||||||
update_flag = true
|
|
||||||
copy_h = h.dup
|
|
||||||
last_index = last_index + 1
|
|
||||||
copy_h["filename"] = copy_h["filename"].sub(/\d+/){|ff| last_index.to_s}
|
|
||||||
copy_h["name"].keys.each do |locale|
|
|
||||||
copy_h["name"][locale] = copy_h["name"][locale].sub(/\d+/){|ff| last_index.to_s}
|
|
||||||
end
|
|
||||||
widget_info << copy_h
|
|
||||||
Bundler.with_clean_env{%x[cp -f #{app_path}/modules/announcement/_#{h["filename"]}.html.erb #{folder}modules/announcement/_#{copy_h["filename"]}.html.erb]}
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
if update_flag
|
end
|
||||||
info["widgets"] = widget_info
|
filename = folder+'assets/stylesheets/template/base/_variables.scss'
|
||||||
puts "Writing json #{info["widgets"].count} in #{info_json_file}"
|
texts = File.open(filename,'r:UTF-8') do |f|
|
||||||
begin
|
f.read
|
||||||
info_json = JSON.pretty_generate(info).gsub(":[",":[\n").gsub(":{",":{\n")
|
end.force_encoding('UTF-8')
|
||||||
rescue
|
s1 = texts.scan(/{|}/)
|
||||||
info_json = info.to_s.gsub("=>",": \n")
|
if s1.count % 2 != 0
|
||||||
|
i = texts.rindex(s1[-1])
|
||||||
|
texts[i] = ""
|
||||||
|
end
|
||||||
|
regex_pattern = /.response-content {\n justify-self: auto;\n}|.response-content {\n position: static;\n}|.response-content {\n position: relative;\n}/m #|.response-content[^{]*{[^}]*@media[^{]*{[^{]*}[^{]*@media[^{]*{[^{]*}[^}]*}[^}]*}
|
||||||
|
if !texts.include? "$font-h1:"
|
||||||
|
texts = "$font-h1: 1.5rem;\n$font-h2: 1.35rem;\n$font-h3: 1.2rem;\n$font-h4: 1.1rem;\n$font-h5: 1rem;\n$font-h6: 0.9rem;\n\n" + texts
|
||||||
|
end
|
||||||
|
if !texts.include? "$main-font:"
|
||||||
|
texts = "$main-font: Arial, \"微軟正黑體\", \"Helvetica Neue\", Helvetica, sans-serif;\n" + texts
|
||||||
|
end
|
||||||
|
if !texts.include? "$theme-white"
|
||||||
|
texts = "$theme-white: #fff;\n" + texts
|
||||||
|
end
|
||||||
|
File.open(filename,'w') do |f|
|
||||||
|
f.write texts
|
||||||
|
end
|
||||||
|
tp_text = File.read(folder+'assets/stylesheets/template/template.scss').force_encoding('UTF-8') rescue ''
|
||||||
|
tp_last_text = tp_text
|
||||||
|
tp_text.scan(/@import.*http.*;/).each do |pat|
|
||||||
|
if pat.scan(/@import\W+url/).count==0
|
||||||
|
pat1 = pat.sub(/@import\W/,"@import url(")
|
||||||
|
pat1 = pat1.sub(/;/,");")
|
||||||
|
tp_last_text = tp_last_text.sub(pat,pat1)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if tp_last_text != tp_text
|
||||||
|
File.open(folder+'assets/stylesheets/template/template.scss','w') do |f|
|
||||||
|
f.write tp_last_text
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if texts.split(regex_pattern).count >= 1
|
||||||
|
auto_save_text = texts.scan(regex_pattern).join('')
|
||||||
|
File.open(folder+'assets/stylesheets/template/base/_autobackup.bak', 'a') do |file|
|
||||||
|
file.puts auto_save_text
|
||||||
|
end
|
||||||
|
File.open(filename, 'w') do |file|
|
||||||
|
file.write (texts.split(regex_pattern).join('') + check_texts[1])
|
||||||
|
end
|
||||||
|
else
|
||||||
|
check_texts.each do |check_text|
|
||||||
|
if !texts.include?(check_text)
|
||||||
|
puts "editing #{folder}assets/stylesheets/template/base/_variables.scss"
|
||||||
|
texts = texts + check_text
|
||||||
|
File.open(filename, 'w') do |file|
|
||||||
|
file.write(texts)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
File.open(info_json_file,"w+"){|f| f.write(info_json)}
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
rescue => e
|
rescue => e
|
||||||
puts e
|
puts "not found #{folder}assets/stylesheets/template/base/_variables.scss"
|
||||||
puts "There has some error when checking announcement widgets"
|
end
|
||||||
|
begin
|
||||||
|
puts "updating announcement show page"
|
||||||
|
Bundler.with_clean_env{%x[cp -f #{app_path}/modules/announcement/show.html.erb #{folder}modules/announcement/show.html.erb]}
|
||||||
|
rescue
|
||||||
|
puts "There has some error in updating announcement show page"
|
||||||
|
end
|
||||||
|
info_json_file = "#{folder}modules/announcement/info.json"
|
||||||
|
if File.exist?(info_json_file)
|
||||||
|
begin
|
||||||
|
file_text = File.read(info_json_file) rescue ""
|
||||||
|
encode_file_text = file_text.encode("UTF-8", "UTF-8", invalid: :replace, replace: "???")
|
||||||
|
next if (encode_file_text.include?("???") rescue true)
|
||||||
|
info = JSON.parse(encode_file_text) rescue {}
|
||||||
|
flag = (info.count != 0 rescue false)
|
||||||
|
if flag
|
||||||
|
puts "Checking announcement widgets"
|
||||||
|
widget_info = info["widgets"].sort_by{|h| h["filename"].to_i} rescue []
|
||||||
|
update_flag = false
|
||||||
|
last_index = widget_info[-1]["filename"].match(/\d+/)[0].to_i rescue nil
|
||||||
|
if !last_index.nil?
|
||||||
|
default_announcement_widget_info.each do |h|
|
||||||
|
name_without_index = h["name"]["zh_tw"].sub(/\d+/,'')
|
||||||
|
if (widget_info.select{|hh| hh["name"]["zh_tw"].include?(name_without_index)}.count == 0)
|
||||||
|
update_flag = true
|
||||||
|
copy_h = h.dup
|
||||||
|
last_index = last_index + 1
|
||||||
|
copy_h["filename"] = copy_h["filename"].sub(/\d+/){|ff| last_index.to_s}
|
||||||
|
copy_h["name"].keys.each do |locale|
|
||||||
|
copy_h["name"][locale] = copy_h["name"][locale].sub(/\d+/){|ff| last_index.to_s}
|
||||||
|
end
|
||||||
|
widget_info << copy_h
|
||||||
|
Bundler.with_clean_env{%x[cp -f #{app_path}/modules/announcement/_#{h["filename"]}.html.erb #{folder}modules/announcement/_#{copy_h["filename"]}.html.erb]}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if update_flag
|
||||||
|
info["widgets"] = widget_info
|
||||||
|
puts "Writing json #{info["widgets"].count} in #{info_json_file}"
|
||||||
|
begin
|
||||||
|
info_json = JSON.pretty_generate(info).gsub(":[",":[\n").gsub(":{",":{\n")
|
||||||
|
rescue
|
||||||
|
info_json = info.to_s.gsub("=>",": \n")
|
||||||
|
end
|
||||||
|
File.open(info_json_file,"w+"){|f| f.write(info_json)}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
rescue => e
|
||||||
|
puts e
|
||||||
|
puts "There has some error when checking announcement widgets"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
if old_gemfile_text != new_gemfile_text
|
||||||
if old_gemfile_text != new_gemfile_text
|
unicorn_rails = %x[which unicorn_rails].sub("\n",'')
|
||||||
unicorn_rails = %x[which unicorn_rails].sub("\n",'')
|
puts 'updating gemfile'
|
||||||
puts 'updating gemfile'
|
Bundler.with_clean_env{%x[cp -f '#{env_pwd}'/Gemfile '#{env_pwd}'/Gemfile.bak123]}
|
||||||
Bundler.with_clean_env{%x[cp -f '#{env_pwd}'/Gemfile '#{env_pwd}'/Gemfile.bak123]}
|
Bundler.with_clean_env{%x[cp -f '#{app_path}'/temp_file/Gemfile '#{env_pwd}'/Gemfile]}
|
||||||
Bundler.with_clean_env{%x[cp -f '#{app_path}'/temp_file/Gemfile '#{env_pwd}'/Gemfile]}
|
#command4 = ";cp -rf #{app_path}/temp_file/app #{env_pwd}"
|
||||||
#command4 = ";cp -rf #{app_path}/temp_file/app #{env_pwd}"
|
command4 = ""
|
||||||
command4 = ""
|
log_development = File.mtime(env_pwd+'/log/development.log').strftime('%Y%m%d%H%M').to_i rescue 0
|
||||||
log_development = File.mtime(env_pwd+'/log/development.log').strftime('%Y%m%d%H%M').to_i rescue 0
|
log_production = File.mtime(env_pwd+'/log/production.log').strftime('%Y%m%d%H%M').to_i rescue 0
|
||||||
log_production = File.mtime(env_pwd+'/log/production.log').strftime('%Y%m%d%H%M').to_i rescue 0
|
if log_development > log_production
|
||||||
if log_development > log_production
|
mode = 'development'
|
||||||
mode = 'development'
|
else
|
||||||
else
|
mode = 'production'
|
||||||
mode = 'production'
|
|
||||||
end
|
|
||||||
files = Dir[env_pwd+'/Gemfile.lock']
|
|
||||||
dir_name = env_pwd.split('/')[-1]
|
|
||||||
watch_dog = %x[screen -ls auto_reopen_#{dir_name}]
|
|
||||||
if watch_dog.scan("auto_reopen_#{dir_name}").count != 0
|
|
||||||
Bundler.with_clean_env{%x[screen -ls | grep auto_reopen_#{dir_name} | cut -d. -f1 | awk '{print $1}' | xargs kill]}
|
|
||||||
end
|
|
||||||
if %x[ruby -v].scan(/\d\.\d\.\d/)[0] == '2.1.3'
|
|
||||||
install_cmd = 'rvm install 2.1.10 && rvm use default 2.1.10;'
|
|
||||||
use_cmd = 'source ~/.rvm/scripts/rvm && rvm use 2.1.10 --default;'
|
|
||||||
else
|
|
||||||
install_cmd = ''
|
|
||||||
use_cmd = ''
|
|
||||||
end
|
|
||||||
#if files.count ==0
|
|
||||||
# command1 = "gem install bundler -v 1.17.3 ; bundle update --all"
|
|
||||||
#else
|
|
||||||
command1 = "gem install bundler -v 1.17.3 ; bundle update --all"
|
|
||||||
#end
|
|
||||||
filedata = File.read(env_pwd+"/built_in_extensions.rb")
|
|
||||||
exist_str = "gem 'patchfile', git: 'http://gitlab.tp.rulingcom.com/chiu/patch_file.git'"
|
|
||||||
if filedata.include? exist_str
|
|
||||||
puts "patchfile exist"
|
|
||||||
else
|
|
||||||
file = env_pwd+"/built_in_extensions.rb"
|
|
||||||
open(file, 'a') { |f|
|
|
||||||
f.puts exist_str
|
|
||||||
}
|
|
||||||
end
|
|
||||||
all_command = "#{install_cmd} #{command1} #{command4} "
|
|
||||||
watch_dog_cmd = "watch -n 30 \'unset UNICORN_FD && bundle exec #{unicorn_rails} -c config/unicorn.rb -D -E #{mode}\'"
|
|
||||||
#file = File.new(File.join(env_pwd,'bundle_update_background.sh'),"w")
|
|
||||||
#file.write(all_command)
|
|
||||||
#file.chmod(0755)
|
|
||||||
#file.close
|
|
||||||
a = Thread.start do
|
|
||||||
Bundler.with_clean_env do
|
|
||||||
puts env_pwd
|
|
||||||
puts mode
|
|
||||||
exec("cd #{env_pwd} && env -i HOME=\"$HOME\" bash -l -c \"#{all_command}\" ;screen -d -m -S auto_reopen_#{dir_name} bash -c \"#{use_cmd} kill -s TERM `cat tmp/pids/unicorn.pid` ; unset UNICORN_FD ; bundle exec #{unicorn_rails} -c config/unicorn.rb -D -E #{mode};#{watch_dog_cmd}\" ")
|
|
||||||
end
|
end
|
||||||
|
files = Dir[env_pwd+'/Gemfile.lock']
|
||||||
|
dir_name = env_pwd.split('/')[-1]
|
||||||
|
watch_dog = %x[screen -ls auto_reopen_#{dir_name}]
|
||||||
|
if watch_dog.scan("auto_reopen_#{dir_name}").count != 0
|
||||||
|
Bundler.with_clean_env{%x[screen -ls | grep auto_reopen_#{dir_name} | cut -d. -f1 | awk '{print $1}' | xargs kill]}
|
||||||
|
end
|
||||||
|
if %x[ruby -v].scan(/\d\.\d\.\d/)[0] == '2.1.3'
|
||||||
|
install_cmd = 'rvm install 2.1.10 && rvm use default 2.1.10;'
|
||||||
|
use_cmd = 'source ~/.rvm/scripts/rvm && rvm use 2.1.10 --default;'
|
||||||
|
else
|
||||||
|
install_cmd = ''
|
||||||
|
use_cmd = ''
|
||||||
|
end
|
||||||
|
#if files.count ==0
|
||||||
|
# command1 = "gem install bundler -v 1.17.3 ; bundle update --all"
|
||||||
|
#else
|
||||||
|
command1 = "gem install bundler -v 1.17.3 ; bundle update --all"
|
||||||
|
#end
|
||||||
|
filedata = File.read(env_pwd+"/built_in_extensions.rb")
|
||||||
|
exist_str = "gem 'patchfile', git: 'http://gitlab.tp.rulingcom.com/chiu/patch_file.git'"
|
||||||
|
if filedata.include? exist_str
|
||||||
|
puts "patchfile exist"
|
||||||
|
else
|
||||||
|
file = env_pwd+"/built_in_extensions.rb"
|
||||||
|
open(file, 'a') { |f|
|
||||||
|
f.puts exist_str
|
||||||
|
}
|
||||||
|
end
|
||||||
|
all_command = "#{install_cmd} #{command1} #{command4} "
|
||||||
|
watch_dog_cmd = "watch -n 30 \'unset UNICORN_FD && bundle exec #{unicorn_rails} -c config/unicorn.rb -D -E #{mode}\'"
|
||||||
|
#file = File.new(File.join(env_pwd,'bundle_update_background.sh'),"w")
|
||||||
|
#file.write(all_command)
|
||||||
|
#file.chmod(0755)
|
||||||
|
#file.close
|
||||||
|
a = Thread.start do
|
||||||
|
Bundler.with_clean_env do
|
||||||
|
puts env_pwd
|
||||||
|
puts mode
|
||||||
|
exec("cd #{env_pwd} && env -i HOME=\"$HOME\" bash -l -c \"#{all_command}\" ;screen -d -m -S auto_reopen_#{dir_name} bash -c \"#{use_cmd} kill -s TERM `cat tmp/pids/unicorn.pid` ; unset UNICORN_FD ; bundle exec #{unicorn_rails} -c config/unicorn.rb -D -E #{mode};#{watch_dog_cmd}\" ")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
now_priority = Thread.current.priority.to_i
|
||||||
|
system('sleep 2')
|
||||||
|
a.priority = now_priority + 2
|
||||||
|
a.run
|
||||||
|
#Thread.exit
|
||||||
|
else
|
||||||
|
dir_name = env_pwd.split('/')[-1]
|
||||||
|
watch_dog = %x[screen -ls auto_reopen_#{dir_name}]
|
||||||
|
if watch_dog.scan("auto_reopen_#{dir_name}").count != 0
|
||||||
|
Bundler.with_clean_env{%x[screen -ls | grep auto_reopen_#{dir_name} | cut -d. -f1 | awk '{print $1}' | xargs kill]}
|
||||||
|
end
|
||||||
|
#system("cp -rf #{app_path}/temp_file/app #{env_pwd}")
|
||||||
end
|
end
|
||||||
now_priority = Thread.current.priority.to_i
|
|
||||||
system('sleep 2')
|
|
||||||
a.priority = now_priority + 2
|
|
||||||
a.run
|
|
||||||
#Thread.exit
|
|
||||||
else
|
|
||||||
dir_name = env_pwd.split('/')[-1]
|
|
||||||
watch_dog = %x[screen -ls auto_reopen_#{dir_name}]
|
|
||||||
if watch_dog.scan("auto_reopen_#{dir_name}").count != 0
|
|
||||||
Bundler.with_clean_env{%x[screen -ls | grep auto_reopen_#{dir_name} | cut -d. -f1 | awk '{print $1}' | xargs kill]}
|
|
||||||
end
|
|
||||||
#system("cp -rf #{app_path}/temp_file/app #{env_pwd}")
|
|
||||||
end
|
end
|
||||||
# Describe your gem and declare its dependencies:
|
# Describe your gem and declare its dependencies:
|
||||||
Gem::Specification.new do |s|
|
Gem::Specification.new do |s|
|
||||||
|
|
Loading…
Reference in New Issue