* fix broken tests because of removal of diagnostics, and fix bad logging pattern
This commit is contained in:
parent
9ad521fa71
commit
8a84ff5609
|
|
@ -3,7 +3,7 @@ require 'resque-lonely_job'
|
||||||
|
|
||||||
module JamRuby
|
module JamRuby
|
||||||
class BatchEmailJob
|
class BatchEmailJob
|
||||||
extend Resque::Plugins::LonelyJob
|
extend Resque::Plugins::JamLonelyJob
|
||||||
|
|
||||||
@@log = Logging.logger[BatchEmailJob]
|
@@log = Logging.logger[BatchEmailJob]
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ module JamRuby
|
||||||
|
|
||||||
# executes a mix of tracks, creating a final output mix
|
# executes a mix of tracks, creating a final output mix
|
||||||
class IcecastConfigWriter
|
class IcecastConfigWriter
|
||||||
extend Resque::Plugins::LonelyJob
|
extend Resque::Plugins::JamLonelyJob
|
||||||
|
|
||||||
@@log = Logging.logger[IcecastConfigWriter]
|
@@log = Logging.logger[IcecastConfigWriter]
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
require 'resque'
|
require 'resque'
|
||||||
require 'resque-lonely_job'
|
|
||||||
|
|
||||||
ENV['FORK_PER_JOB'] = 'false'
|
ENV['FORK_PER_JOB'] = 'false'
|
||||||
|
|
||||||
|
|
@ -63,19 +62,21 @@ module JamRuby
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
require 'resque-lonely_job'
|
||||||
|
|
||||||
# for jobs that extend lonely job, we override around_perform already implemented in LonelyJob, and call into it
|
# for jobs that extend lonely job, we override around_perform already implemented in LonelyJob, and call into it
|
||||||
module Resque
|
module Resque
|
||||||
module Plugins
|
module Plugins
|
||||||
module LonelyJob
|
module JamLonelyJob
|
||||||
def around_perform(*args)
|
def around_perform(*args)
|
||||||
Stats.timer('job.stats') do
|
Stats.timer('job.stats') do
|
||||||
begin
|
super
|
||||||
yield
|
|
||||||
ensure
|
|
||||||
unlock_queue(*args)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Resque::Plugins::JamLonelyJob.module_eval { include Resque::Plugins::LonelyJob }
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ require 'digest/md5'
|
||||||
module JamRuby
|
module JamRuby
|
||||||
|
|
||||||
class ActiveMusicSessionCleaner
|
class ActiveMusicSessionCleaner
|
||||||
extend Resque::Plugins::LonelyJob
|
extend Resque::Plugins::JamLonelyJob
|
||||||
|
|
||||||
attr_accessor :interval
|
attr_accessor :interval
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ module JamRuby
|
||||||
|
|
||||||
# periodically scheduled to find jobs that need retrying, and cleanup activities
|
# periodically scheduled to find jobs that need retrying, and cleanup activities
|
||||||
class AudioMixerRetry
|
class AudioMixerRetry
|
||||||
extend Resque::Plugins::LonelyJob
|
extend Resque::Plugins::JamLonelyJob
|
||||||
|
|
||||||
@queue = :scheduled_audiomixer_retry
|
@queue = :scheduled_audiomixer_retry
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,9 +2,6 @@
|
||||||
module JamRuby
|
module JamRuby
|
||||||
class CleanupFacebookSignup
|
class CleanupFacebookSignup
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@queue = :scheduled_cleanup_facebook_signup
|
@queue = :scheduled_cleanup_facebook_signup
|
||||||
|
|
||||||
@@log = Logging.logger[CleanupFacebookSignup]
|
@@log = Logging.logger[CleanupFacebookSignup]
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
module JamRuby
|
module JamRuby
|
||||||
class DailySessionEmailer
|
class DailySessionEmailer
|
||||||
extend Resque::Plugins::LonelyJob
|
extend Resque::Plugins::JamLonelyJob
|
||||||
|
|
||||||
@queue = :scheduled_daily_session_emailer
|
@queue = :scheduled_daily_session_emailer
|
||||||
@@log = Logging.logger[DailySessionEmailer]
|
@@log = Logging.logger[DailySessionEmailer]
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ module JamRuby
|
||||||
|
|
||||||
# periodically scheduled to find jobs that need retrying
|
# periodically scheduled to find jobs that need retrying
|
||||||
class IcecastConfigRetry
|
class IcecastConfigRetry
|
||||||
extend Resque::Plugins::LonelyJob
|
extend Resque::Plugins::JamLonelyJob
|
||||||
|
|
||||||
@queue = :scheduled_icecast_config_retry
|
@queue = :scheduled_icecast_config_retry
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -9,11 +9,13 @@ module JamRuby
|
||||||
# http://blog.bignerdranch.com/1643-never-use-resque-for-serial-jobs/
|
# http://blog.bignerdranch.com/1643-never-use-resque-for-serial-jobs/
|
||||||
# periodically scheduled to find sources that need to be brought down, or alternatively, it seems the client failed to start sourcing
|
# periodically scheduled to find sources that need to be brought down, or alternatively, it seems the client failed to start sourcing
|
||||||
class IcecastSourceCheck
|
class IcecastSourceCheck
|
||||||
extend Resque::Plugins::LonelyJob
|
extend Resque::Plugins::JamLonelyJob
|
||||||
|
|
||||||
@queue = :scheduled_icecast_source_check
|
@queue = :scheduled_icecast_source_check
|
||||||
|
|
||||||
@@log = Logging.logger[IcecastSourceCheck]
|
def log
|
||||||
|
@log || Logging.logger[IcecastSourceCheck]
|
||||||
|
end
|
||||||
|
|
||||||
def self.lock_timeout
|
def self.lock_timeout
|
||||||
# this should be enough time to make sure the job has finished, but not so long that the system isn't recovering from a abandoned job
|
# this should be enough time to make sure the job has finished, but not so long that the system isn't recovering from a abandoned job
|
||||||
|
|
@ -21,11 +23,7 @@ module JamRuby
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.perform
|
def self.perform
|
||||||
@@log.debug("waking up")
|
IcecastSourceCheck.new.run
|
||||||
|
|
||||||
IcecastSourceCheck.new.run
|
|
||||||
|
|
||||||
@@log.debug("done")
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -35,6 +33,8 @@ module JamRuby
|
||||||
# ** listeners > 0 and sourced is DOWN (false)
|
# ** listeners > 0 and sourced is DOWN (false)
|
||||||
# ** listeners == 0 and sourced is UP (true)
|
# ** listeners == 0 and sourced is UP (true)
|
||||||
|
|
||||||
|
log.debug("waking up")
|
||||||
|
|
||||||
IcecastMount.find_each(lock: true, :conditions => "( (listeners > 0 AND sourced = FALSE) OR (listeners = 0 AND sourced = TRUE) ) AND ( sourced_needs_changing_at IS NULL OR sourced_needs_changing_at < (NOW() - interval '#{APP_CONFIG.icecast_max_sourced_changed} second') ) ", :batch_size => 100) do |mount|
|
IcecastMount.find_each(lock: true, :conditions => "( (listeners > 0 AND sourced = FALSE) OR (listeners = 0 AND sourced = TRUE) ) AND ( sourced_needs_changing_at IS NULL OR sourced_needs_changing_at < (NOW() - interval '#{APP_CONFIG.icecast_max_sourced_changed} second') ) ", :batch_size => 100) do |mount|
|
||||||
if mount.music_session_id
|
if mount.music_session_id
|
||||||
mount.with_lock do
|
mount.with_lock do
|
||||||
|
|
@ -42,6 +42,8 @@ module JamRuby
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
log.debug("done")
|
||||||
end
|
end
|
||||||
|
|
||||||
def handle_notifications(mount)
|
def handle_notifications(mount)
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ require 'digest/md5'
|
||||||
|
|
||||||
module JamRuby
|
module JamRuby
|
||||||
class MusicSessionScheduler
|
class MusicSessionScheduler
|
||||||
extend Resque::Plugins::LonelyJob
|
extend Resque::Plugins::JamLonelyJob
|
||||||
|
|
||||||
@queue = :music_session_scheduler
|
@queue = :music_session_scheduler
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
module JamRuby
|
module JamRuby
|
||||||
class NewMusicianEmailer
|
class NewMusicianEmailer
|
||||||
extend Resque::Plugins::LonelyJob
|
extend Resque::Plugins::JamLonelyJob
|
||||||
|
|
||||||
@queue = :scheduled_new_musician_emailer
|
@queue = :scheduled_new_musician_emailer
|
||||||
@@log = Logging.logger[NewMusicianEmailer]
|
@@log = Logging.logger[NewMusicianEmailer]
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ module JamRuby
|
||||||
|
|
||||||
# periodically scheduled to find recordings to cleanup
|
# periodically scheduled to find recordings to cleanup
|
||||||
class RecordingsCleaner
|
class RecordingsCleaner
|
||||||
extend Resque::Plugins::LonelyJob
|
extend Resque::Plugins::JamLonelyJob
|
||||||
|
|
||||||
@queue = :recordings_cleaner
|
@queue = :recordings_cleaner
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
module JamRuby
|
module JamRuby
|
||||||
class ScheduledMusicSessionCleaner
|
class ScheduledMusicSessionCleaner
|
||||||
extend Resque::Plugins::LonelyJob
|
extend Resque::Plugins::JamLonelyJob
|
||||||
|
|
||||||
@queue = :scheduled_music_session_cleaner
|
@queue = :scheduled_music_session_cleaner
|
||||||
@@log = Logging.logger[ScheduledMusicSessionCleaner]
|
@@log = Logging.logger[ScheduledMusicSessionCleaner]
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ module JamRuby
|
||||||
|
|
||||||
# periodically scheduled to find jobs that need retrying
|
# periodically scheduled to find jobs that need retrying
|
||||||
class ScoreHistorySweeper
|
class ScoreHistorySweeper
|
||||||
extend Resque::Plugins::LonelyJob
|
extend Resque::Plugins::JamLonelyJob
|
||||||
|
|
||||||
@queue = :score_history_sweeper
|
@queue = :score_history_sweeper
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -8,13 +8,25 @@ module JamRuby
|
||||||
|
|
||||||
# creates stats to send to influx periodically
|
# creates stats to send to influx periodically
|
||||||
class StatsMaker
|
class StatsMaker
|
||||||
extend Resque::Plugins::LonelyJob
|
extend Resque::Plugins::JamLonelyJob
|
||||||
|
|
||||||
@queue = :stats_maker
|
@queue = :scheduled_db_metrics
|
||||||
|
|
||||||
|
def log
|
||||||
|
@log || Logging.logger[StatsMaker]
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.lock_timeout
|
||||||
|
120
|
||||||
|
end
|
||||||
|
|
||||||
@@log = Logging.logger['StatsMaker']
|
|
||||||
|
|
||||||
def self.perform
|
def self.perform
|
||||||
|
StatsMaker.new.run
|
||||||
|
end
|
||||||
|
|
||||||
|
def run
|
||||||
|
log.debug("starting...")
|
||||||
Stats.write('connection', Connection.stats)
|
Stats.write('connection', Connection.stats)
|
||||||
Stats.write('users', User.stats)
|
Stats.write('users', User.stats)
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ require 'digest/md5'
|
||||||
|
|
||||||
module JamRuby
|
module JamRuby
|
||||||
class UnusedMusicNotationCleaner
|
class UnusedMusicNotationCleaner
|
||||||
extend Resque::Plugins::LonelyJob
|
extend Resque::Plugins::JamLonelyJob
|
||||||
|
|
||||||
@queue = :unused_music_notation_cleaner
|
@queue = :unused_music_notation_cleaner
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
module JamRuby
|
module JamRuby
|
||||||
class UserProgressEmailer
|
class UserProgressEmailer
|
||||||
extend Resque::Plugins::LonelyJob
|
extend Resque::Plugins::JamLonelyJob
|
||||||
|
|
||||||
@queue = :scheduled_user_progress_emailer
|
@queue = :scheduled_user_progress_emailer
|
||||||
@@log = Logging.logger[UserProgressEmailer]
|
@@log = Logging.logger[UserProgressEmailer]
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,8 @@
|
||||||
|
|
||||||
// related to listen
|
// related to listen
|
||||||
function stateChange(e, data) {
|
function stateChange(e, data) {
|
||||||
var $listenLink = e.element;
|
var $listenLink = e.element; // TODO: this is empty
|
||||||
|
console.log(e,$(this))
|
||||||
var $listenText = $('.listen-link-text', $listenLink);
|
var $listenText = $('.listen-link-text', $listenLink);
|
||||||
var $listenDetails = $('.listen-link-details', $listenLink);
|
var $listenDetails = $('.listen-link-details', $listenLink);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,9 @@
|
||||||
class ApiController < ApplicationController
|
class ApiController < ApplicationController
|
||||||
|
|
||||||
@@log = Logging.logger[ApiController]
|
def log
|
||||||
|
@log || Logging.logger[ApiController]
|
||||||
|
end
|
||||||
|
|
||||||
@@html_encoder = HTMLEntities.new
|
@@html_encoder = HTMLEntities.new
|
||||||
|
|
||||||
# define common error handlers
|
# define common error handlers
|
||||||
|
|
@ -21,11 +24,11 @@ class ApiController < ApplicationController
|
||||||
render "errors/conflict_error", :status => 409
|
render "errors/conflict_error", :status => 409
|
||||||
end
|
end
|
||||||
rescue_from 'ActiveRecord::RecordNotFound' do |exception|
|
rescue_from 'ActiveRecord::RecordNotFound' do |exception|
|
||||||
@@log.debug(exception)
|
log.debug(exception)
|
||||||
render :json => { :errors => { :resource => ["record not found"] } }, :status => 404
|
render :json => { :errors => { :resource => ["record not found"] } }, :status => 404
|
||||||
end
|
end
|
||||||
rescue_from 'PG::Error' do |exception|
|
rescue_from 'PG::Error' do |exception|
|
||||||
@@log.debug(exception)
|
log.debug(exception)
|
||||||
if exception.to_s.include? "duplicate key value violates unique constraint"
|
if exception.to_s.include? "duplicate key value violates unique constraint"
|
||||||
render :json => { :errors => { :resource => ["resource already exists"] } }, :status => 409 # 409 = conflict
|
render :json => { :errors => { :resource => ["resource already exists"] } }, :status => 409 # 409 = conflict
|
||||||
else
|
else
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,9 @@ class ApiRecordingsController < ApiController
|
||||||
|
|
||||||
respond_to :json
|
respond_to :json
|
||||||
|
|
||||||
@@log = Logging.logger[ApiRecordingsController]
|
def log
|
||||||
|
@log || Logging.logger[ApiRecordingsController]
|
||||||
|
end
|
||||||
|
|
||||||
def index
|
def index
|
||||||
# lists recordings created by for the current user
|
# lists recordings created by for the current user
|
||||||
|
|
|
||||||
|
|
@ -8,8 +8,9 @@ class ApiUserSyncsController < ApiController
|
||||||
|
|
||||||
respond_to :json
|
respond_to :json
|
||||||
|
|
||||||
@@log = Logging.logger[ApiUserSyncsController]
|
def log
|
||||||
|
@log || Logging.logger[ApiUserSyncsController]
|
||||||
|
end
|
||||||
|
|
||||||
def show
|
def show
|
||||||
@user_sync = UserSync.show(params[:user_sync_id], current_user.id)
|
@user_sync = UserSync.show(params[:user_sync_id], current_user.id)
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,10 @@ require 'js_connect'
|
||||||
|
|
||||||
class VanillaForumsController < ApplicationController
|
class VanillaForumsController < ApplicationController
|
||||||
|
|
||||||
@@log = Logging.logger[VanillaForumsController]
|
|
||||||
|
def log
|
||||||
|
@log || Logging.logger[VanillaForumsController ]
|
||||||
|
end
|
||||||
|
|
||||||
# displays the embedded forum
|
# displays the embedded forum
|
||||||
# see http://vanillaforums.com/blog/jsconnect-technical-documentation-for-embedded-sso/
|
# see http://vanillaforums.com/blog/jsconnect-technical-documentation-for-embedded-sso/
|
||||||
|
|
@ -43,9 +46,9 @@ class VanillaForumsController < ApplicationController
|
||||||
'photourl' => current_user.resolved_photo_url,
|
'photourl' => current_user.resolved_photo_url,
|
||||||
'uniqueid' => current_user.id}
|
'uniqueid' => current_user.id}
|
||||||
|
|
||||||
@@log.debug("user is logged in: #{user}")
|
log.debug("user is logged in: #{user}")
|
||||||
else
|
else
|
||||||
@@log.debug("user is not logged in")
|
log.debug("user is not logged in")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,3 @@
|
||||||
@@log = Logging.logger['EmailInitializer']
|
|
||||||
|
|
||||||
ActionMailer::Base.raise_delivery_errors = true
|
ActionMailer::Base.raise_delivery_errors = true
|
||||||
ActionMailer::Base.delivery_method = GenericState.allow_emails? ? :smtp : :test
|
ActionMailer::Base.delivery_method = GenericState.allow_emails? ? :smtp : :test
|
||||||
ActionMailer::Base.smtp_settings = {
|
ActionMailer::Base.smtp_settings = {
|
||||||
|
|
@ -12,4 +10,4 @@ ActionMailer::Base.smtp_settings = {
|
||||||
:enable_starttls_auto => Rails.application.config.email_smtp_starttls_auto
|
:enable_starttls_auto => Rails.application.config.email_smtp_starttls_auto
|
||||||
}
|
}
|
||||||
|
|
||||||
@@log.debug("ActionMailer.delivery_method = #{ActionMailer::Base.delivery_method}")
|
Rails.logger.debug("ActionMailer.delivery_method = #{ActionMailer::Base.delivery_method}")
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,9 @@
|
||||||
module Middlewares
|
module Middlewares
|
||||||
class ClearDuplicatedSession
|
class ClearDuplicatedSession
|
||||||
|
|
||||||
@@log = Logging.logger[ClearDuplicatedSession]
|
def log
|
||||||
|
@log || Logging.logger[ClearDuplicatedSession]
|
||||||
|
end
|
||||||
|
|
||||||
def initialize(app)
|
def initialize(app)
|
||||||
@app = app
|
@app = app
|
||||||
|
|
@ -53,7 +55,7 @@ module Middlewares
|
||||||
# Sets expiration date = 1970-01-01 to the cookie, this way browser will
|
# Sets expiration date = 1970-01-01 to the cookie, this way browser will
|
||||||
# note the cookie is expired and will delete it
|
# note the cookie is expired and will delete it
|
||||||
def delete_session_cookie_for_current_domain(env, headers)
|
def delete_session_cookie_for_current_domain(env, headers)
|
||||||
@@log.debug "deleting default domain session cookie"
|
log.debug "deleting default domain session cookie"
|
||||||
::Rack::Utils.set_cookie_header!(
|
::Rack::Utils.set_cookie_header!(
|
||||||
headers, # contains response headers
|
headers, # contains response headers
|
||||||
get_session_key(env), # gets the cookie session name, '_session_cookie' - for this example
|
get_session_key(env), # gets the cookie session name, '_session_cookie' - for this example
|
||||||
|
|
|
||||||
|
|
@ -74,11 +74,6 @@ describe "Reconnect", :js => true, :type => :feature, :capybara_feature => true
|
||||||
|
|
||||||
# but.. after a few seconds, it should reconnect on it's own
|
# but.. after a few seconds, it should reconnect on it's own
|
||||||
page.should_not have_selector('.no-websocket-connection')
|
page.should_not have_selector('.no-websocket-connection')
|
||||||
|
|
||||||
# confirm that a diagnostic was written
|
|
||||||
Diagnostic.count.should == i + 1
|
|
||||||
diagnostic = Diagnostic.first
|
|
||||||
diagnostic.type.should == Diagnostic::WEBSOCKET_CLOSED_LOCALLY
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# then verify we can create a session
|
# then verify we can create a session
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue