diff --git a/config/initializers/load_config.rb b/config/initializers/load_config.rb index e6874293..0d22eac8 100644 --- a/config/initializers/load_config.rb +++ b/config/initializers/load_config.rb @@ -1 +1,2 @@ APP_CONFIG = YAML.load_file("#{Rails.root}/config/config.yml")[Rails.env] +LDAP_CONFIG = YAML.load_file("#{Rails.root}/config/ldap.yml")[Rails.env] \ No newline at end of file diff --git a/config/initializers/nccu_ldap_connection.rb b/config/initializers/nccu_ldap_connection.rb index 35e9ded8..00e03367 100644 --- a/config/initializers/nccu_ldap_connection.rb +++ b/config/initializers/nccu_ldap_connection.rb @@ -6,20 +6,11 @@ $nccu_ldap_connection module NccuLdapConnection BASE = 'ou=People,dc=nccu,dc=edu,dc=tw' - @ldap_host = { - :host => '127.0.0.1', #140.119.166.23 or 127.0.0.1 - :port => 8001, #389 or 8001 - # :filter => "(uid=#{login_uid})", - # :base => "ou=People,dc=nccu,dc=edu,dc=tw", - :authenticate_info => "cn=uccn,ou=profile,dc=nccu,dc=edu,dc=tw", - :authenticate_pwd => "nccu2ucc" - } - def self.establish - $nccu_ldap_connection = Net::LDAP.new - $nccu_ldap_connection.port = @ldap_host[:port] - $nccu_ldap_connection.host = @ldap_host[:host] - $nccu_ldap_connection.authenticate(@ldap_host[:authenticate_info],@ldap_host[:authenticate_pwd]) + $nccu_ldap_connection = Net::LDAP.new + $nccu_ldap_connection.port =LDAP_CONFIG["port"] + $nccu_ldap_connection.host = LDAP_CONFIG["host"] + $nccu_ldap_connection.authenticate(LDAP_CONFIG["authenticate_info"],LDAP_CONFIG["authenticate_pwd"]) end end \ No newline at end of file diff --git a/config/ldap.yml b/config/ldap.yml new file mode 100644 index 00000000..5c48fc1a --- /dev/null +++ b/config/ldap.yml @@ -0,0 +1,12 @@ +defaults: &defaults + authenticate_info: 'cn=uccn,ou=profile,dc=nccu,dc=edu,dc=tw' + authenticate_pwd: 'nccu2ucc' + +development: + <<: *defaults + host: '127.0.0.1' + port: 8001 +production: + <<: *defaults + host: '140.119.166.23' + port: 389 diff --git a/config/resque.god b/config/resque.god index 6f331dd8..80da5abe 100644 --- a/config/resque.god +++ b/config/resque.god @@ -1,7 +1,14 @@ +#developer pls change here +default_uid = 'kaito' +default_gid = 'staff' + rails_env = 'development' #ENV['RAILS_ENV'] || "production" -rails_root = ENV['RAILS_ROOT'] || "/Users/kaito/Documents/MyWorkspeace/NCCU" + + +rails_root = ENV['RAILS_ROOT'] || File.expand_path("..",File.dirname(__FILE__)) num_workers = rails_env == 'production' ? 5 : 2 + num_workers.times do |num| God.watch do |w| w.dir = "#{rails_root}" @@ -12,8 +19,11 @@ num_workers.times do |num| # w.env = {"QUEUE"=>"critical,high,low", "RAILS_ENV"=>rails_env} w.start = "rake -f #{rails_root}/Rakefile resque:work QUEUE=* RAILS_ENV=#{rails_env}" - w.uid = 'kaito' - w.gid = 'staff' + w.uid = rails_env == 'production' ? nccu : default_uid + w.gid = rails_env == 'production' ? nccu : default_gid + + + w.log = "#{rails_root}/log/god.log" # restart if memory gets too high w.transition(:up, :restart) do |on|