From 093d6791879af9c32eb27bf391eba30049638a17 Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Thu, 27 Apr 2017 09:34:40 +0200 Subject: [PATCH] Load default gems based on bundle config. --- script/scheduler.rb | 16 ++++++++++++---- script/websocket-server.rb | 4 ++++ 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/script/scheduler.rb b/script/scheduler.rb index b4252b866..8ea47d270 100755 --- a/script/scheduler.rb +++ b/script/scheduler.rb @@ -3,8 +3,18 @@ $LOAD_PATH << './lib' require 'rubygems' -require 'daemons' + +# load rails env dir = File.expand_path(File.join(File.dirname(__FILE__), '..')) +Dir.chdir dir +RAILS_ENV = ENV['RAILS_ENV'] || 'development' + +require 'rails/all' +require 'bundler' +Bundler.require(:default, Rails.env) +require File.join(dir, 'config', 'environment') + +require 'daemons' daemon_options = { multiple: false, @@ -22,12 +32,10 @@ Daemons.run_proc(name, daemon_options) do end Dir.chdir dir - RAILS_ENV = ARGV.first || ENV['RAILS_ENV'] || 'development' $stdout.reopen( dir + '/log/' + name + '_out.log', 'w') $stderr.reopen( dir + '/log/' + name + '_err.log', 'w') - require File.join(dir, 'config', 'environment') - require 'scheduler' + require 'scheduler' Scheduler.threads end diff --git a/script/websocket-server.rb b/script/websocket-server.rb index 7affdb355..e72c5d994 100755 --- a/script/websocket-server.rb +++ b/script/websocket-server.rb @@ -14,6 +14,10 @@ require 'daemons' dir = File.expand_path(File.join(File.dirname(__FILE__), '..')) Dir.chdir dir RAILS_ENV = ENV['RAILS_ENV'] || 'development' + +require 'rails/all' +require 'bundler' +Bundler.require(:default, Rails.env) require File.join(dir, 'config', 'environment') require 'sessions'