Fix bug.
This commit is contained in:
parent
300a4a8cba
commit
e237aba5f2
|
@ -36,8 +36,9 @@ class BulletinsController < ApplicationController
|
||||||
annc_depts = annc_depts_translations[locale] rescue []
|
annc_depts = annc_depts_translations[locale] rescue []
|
||||||
end
|
end
|
||||||
I18n.locale = :zh_tw
|
I18n.locale = :zh_tw
|
||||||
if !params[:keyword].blank?
|
keyword = params[:keyword].to_s
|
||||||
keyword = Regexp.new(".*"+params[:keyword]+".*")
|
if keyword.present?
|
||||||
|
keyword = Regexp.new(".*"+keyword+".*")
|
||||||
bulletins = Bulletin.any_of({:title=>keyword},{:subtitle=>keyword},{:text=>keyword})
|
bulletins = Bulletin.any_of({:title=>keyword},{:subtitle=>keyword},{:text=>keyword})
|
||||||
else
|
else
|
||||||
bulletins = Bulletin.all
|
bulletins = Bulletin.all
|
||||||
|
@ -111,8 +112,9 @@ class BulletinsController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
# 計算總筆數 Start
|
# 計算總筆數 Start
|
||||||
if !params[:keyword].blank?
|
keyword = params[:keyword].to_s
|
||||||
keyword = Regexp.new(".*"+params[:keyword]+".*")
|
if keyword.present?
|
||||||
|
keyword = Regexp.new(".*"+keyword+".*")
|
||||||
bulletin_count = Bulletin.any_of({:title=>keyword},{:subtitle=>keyword},{:text=>keyword})
|
bulletin_count = Bulletin.any_of({:title=>keyword},{:subtitle=>keyword},{:text=>keyword})
|
||||||
else
|
else
|
||||||
bulletin_count = Bulletin.all
|
bulletin_count = Bulletin.all
|
||||||
|
|
|
@ -292,7 +292,7 @@ module AnnouncementsHelper
|
||||||
|
|
||||||
|
|
||||||
if @target_action == "index"
|
if @target_action == "index"
|
||||||
filename = overridehtml.nil? ? params[:layout_type] : overridehtml
|
filename = overridehtml.nil? ? params[:layout_type].to_s.split('/').last : overridehtml
|
||||||
f = File.join(Rails.root, 'app', 'templates', "#{@key}", 'modules', 'announcement', "#{filename}.html.erb")
|
f = File.join(Rails.root, 'app', 'templates', "#{@key}", 'modules', 'announcement', "#{filename}.html.erb")
|
||||||
if !File.exists?f
|
if !File.exists?f
|
||||||
f = File.join(Rails.root, 'app', 'templates', "#{@key}", 'modules', 'announcement', "index.html.erb")
|
f = File.join(Rails.root, 'app', 'templates', "#{@key}", 'modules', 'announcement', "index.html.erb")
|
||||||
|
|
|
@ -3,6 +3,19 @@ class Admin::PlaygroundController < OrbitAdminController
|
||||||
before_filter :check_for_testers, :only => "index"
|
before_filter :check_for_testers, :only => "index"
|
||||||
layout "structure"
|
layout "structure"
|
||||||
include Admin::PlaygroundHelper
|
include Admin::PlaygroundHelper
|
||||||
|
begin
|
||||||
|
include BundlerHelper
|
||||||
|
rescue
|
||||||
|
def bundler_with_clean_env
|
||||||
|
if block_given?
|
||||||
|
if Bundler.respond_to?(:with_unbundled_env)
|
||||||
|
Bundler.with_unbundled_env(&Proc.new)
|
||||||
|
else
|
||||||
|
Bundler.with_clean_env(&Proc.new)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
before_action :clean_multithread_model, :only => :command
|
before_action :clean_multithread_model, :only => :command
|
||||||
|
|
||||||
def index
|
def index
|
||||||
|
@ -103,17 +116,17 @@ class Admin::PlaygroundController < OrbitAdminController
|
||||||
File.delete(file) if File.exists?(file)
|
File.delete(file) if File.exists?(file)
|
||||||
else
|
else
|
||||||
mul = Multithread.where(key: 'playground').first
|
mul = Multithread.where(key: 'playground').first
|
||||||
if !mul.nil?
|
if !mul.nil?
|
||||||
render :json => {"alive" => mul.status['alive'], "response" => mul.status['output'][params[:count].to_i..-1], "error" => mul.status['error']}.to_json
|
render :json => {"alive" => mul.status['alive'], "response" => mul.status['output'][params[:count].to_i..-1], "error" => mul.status['error']}.to_json
|
||||||
if !mul.status['alive']
|
if !mul.status['alive']
|
||||||
mul.status['output'] = []
|
mul.status['output'] = []
|
||||||
mul.status['error'] = false
|
mul.status['error'] = false
|
||||||
mul.save
|
mul.save
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
render :json => {"alive" => true, "response" => "finish", "error" => false}.to_json
|
render :json => {"alive" => true, "response" => "finish", "error" => false}.to_json
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
@ -124,34 +137,34 @@ class Admin::PlaygroundController < OrbitAdminController
|
||||||
end
|
end
|
||||||
|
|
||||||
def exec_other_command(command)
|
def exec_other_command(command)
|
||||||
mul = Multithread.where(key: 'playground').first
|
mul = Multithread.where(key: 'playground').first
|
||||||
Thread.new do
|
Thread.new do
|
||||||
begin
|
begin
|
||||||
Bundler.with_clean_env do
|
bundler_with_clean_env do
|
||||||
IO.popen(command,:err=>[:child, :out]) do |stdout|
|
IO.popen(command,:err=>[:child, :out]) do |stdout|
|
||||||
stdout.each do |line|
|
stdout.each do |line|
|
||||||
l = line.chomp
|
l = line.chomp
|
||||||
mul.status['output'] << l
|
mul.status['output'] << l
|
||||||
if l == "rake aborted!"
|
if l == "rake aborted!"
|
||||||
mul.status['error'] = true
|
mul.status['error'] = true
|
||||||
end
|
end
|
||||||
mul.save
|
mul.save
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
mul.status['alive'] = false
|
mul.status['alive'] = false
|
||||||
mul.save
|
mul.save
|
||||||
if command == 'bundle update'
|
if command == 'bundle update'
|
||||||
system('sleep 2')
|
system('sleep 2')
|
||||||
Bundler.with_clean_env{system("UNICORN_PID=\"`fuser tmp/pids/unicorn.sock tmp/sockets/unicorn.sock tmp/unicorn.sock` `cat tmp/pids/unicorn.pid `\" && kill -s USR2 $UNICORN_PID ; n=20; while (kill -0 $UNICORN_PID > /dev/null 2>&1) && test $n -ge 0; do printf '.' && sleep 1 && n=$(( $n - 1 )); done ; if test $n -lt 0; then kill -s TERM $UNICORN_PID; sleep 3; bundle exec unicorn_rails -c config/unicorn.rb -D -E #{Rails.env}; else kill -s QUIT $UNICORN_PID; fi")}
|
bundler_with_clean_env{system("#{RESTART_CMD}")}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
rescue => e
|
rescue => e
|
||||||
mul.status['alive'] = false
|
mul.status['alive'] = false
|
||||||
mul.status['output'] << e.inspect
|
mul.status['output'] << e.inspect
|
||||||
mul.status['error'] = true
|
mul.status['error'] = true
|
||||||
mul.save
|
mul.save
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def bundle_update
|
def bundle_update
|
||||||
|
@ -160,7 +173,7 @@ class Admin::PlaygroundController < OrbitAdminController
|
||||||
end
|
end
|
||||||
|
|
||||||
def restart_server
|
def restart_server
|
||||||
cmd ="UNICORN_PID=\"`fuser tmp/pids/unicorn.sock tmp/sockets/unicorn.sock tmp/unicorn.sock` `cat tmp/pids/unicorn.pid `\" && kill -s USR2 $UNICORN_PID ; n=20; while (kill -0 $UNICORN_PID > /dev/null 2>&1) && test $n -ge 0; do printf '.' && sleep 1 && n=$(( $n - 1 )); done ; if test $n -lt 0; then kill -s TERM $UNICORN_PID; sleep 3; bundle exec unicorn_rails -c config/unicorn.rb -D -E #{Rails.env}; else kill -s QUIT $UNICORN_PID; fi"
|
cmd ="#{RESTART_CMD}"
|
||||||
exec_other_command(cmd)
|
exec_other_command(cmd)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -174,7 +187,7 @@ class Admin::PlaygroundController < OrbitAdminController
|
||||||
unicorn_rails = %x[which unicorn_rails].sub("\n",'')
|
unicorn_rails = %x[which unicorn_rails].sub("\n",'')
|
||||||
content = "UNICORN_PID=\"`fuser tmp/pids/unicorn.sock tmp/sockets/unicorn.sock tmp/unicorn.sock` `cat tmp/pids/unicorn.pid `\" && kill -s TERM $UNICORN_PID ; while (kill -0 $UNICORN_PID > /dev/null 2>&1) ; do printf '.' && sleep 1 ; done ; unset UNICORN_FD; bundle exec unicorn_rails -c config/unicorn.rb -D -E #{mode}"
|
content = "UNICORN_PID=\"`fuser tmp/pids/unicorn.sock tmp/sockets/unicorn.sock tmp/unicorn.sock` `cat tmp/pids/unicorn.pid `\" && kill -s TERM $UNICORN_PID ; while (kill -0 $UNICORN_PID > /dev/null 2>&1) ; do printf '.' && sleep 1 ; done ; unset UNICORN_FD; bundle exec unicorn_rails -c config/unicorn.rb -D -E #{mode}"
|
||||||
Thread.new do
|
Thread.new do
|
||||||
Bundler.with_clean_env{system(content)}
|
bundler_with_clean_env{system(content)}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -176,7 +176,9 @@ class Site
|
||||||
File.open("config/member_extra_db.txt","w+"){|f| f.write(self.member_extra_db)}
|
File.open("config/member_extra_db.txt","w+"){|f| f.write(self.member_extra_db)}
|
||||||
if (defined?(OrbitHelper::SharedHash) && OrbitHelper::SharedHash rescue false)
|
if (defined?(OrbitHelper::SharedHash) && OrbitHelper::SharedHash rescue false)
|
||||||
OrbitHelper::SharedHash['current_site']['site'] = self if @changed && OrbitHelper::SharedHash['current_site']
|
OrbitHelper::SharedHash['current_site']['site'] = self if @changed && OrbitHelper::SharedHash['current_site']
|
||||||
OrbitHelper::SharedHash['privileged_page_count'].value = self.privileged_page_count
|
if OrbitHelper::SharedHash['privileged_page_count']
|
||||||
|
OrbitHelper::SharedHash['privileged_page_count'].value = self.privileged_page_count
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
after_initialize do |record|
|
after_initialize do |record|
|
||||||
|
|
Loading…
Reference in New Issue