aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorXinhui2017-01-12 15:41:31 +0100
committerXinhui2017-01-12 15:41:38 +0100
commitb0f53db2facca6ae040d70ff1d041847e566dc2f (patch)
tree99040b9c374224c0d7254c5156246ab927a4dfbf
parent7494a76f42388c1f9c34c09b65a829c6ca05d829 (diff)
downloadchouette-core-b0f53db2facca6ae040d70ff1d041847e566dc2f.tar.bz2
Set status failed for reflex:codiflign sync on sidekiq restart
Refs #2390
-rw-r--r--app/models/line_referential_sync.rb6
-rw-r--r--app/models/stop_area_referential_sync.rb4
-rw-r--r--app/workers/line_referential_sync_worker.rb2
-rw-r--r--app/workers/stop_area_referential_sync_worker.rb1
-rw-r--r--config/initializers/sidekiq.rb7
5 files changed, 17 insertions, 3 deletions
diff --git a/app/models/line_referential_sync.rb b/app/models/line_referential_sync.rb
index a54d61edb..6730ddd73 100644
--- a/app/models/line_referential_sync.rb
+++ b/app/models/line_referential_sync.rb
@@ -6,6 +6,8 @@ class LineReferentialSync < ActiveRecord::Base
after_commit :perform_sync, :on => :create
validate :multiple_process_validation, :on => :create
+ scope :pending, -> { where(status: [:new, :pending]) }
+
private
def perform_sync
create_sync_message :info, :new
@@ -26,7 +28,7 @@ class LineReferentialSync < ActiveRecord::Base
state :failed
event :run, after: :log_pending do
- transitions :from => [:new, :failed], :to => :pending
+ transitions :from => :new, :to => :pending
end
event :successful, after: :log_successful do
@@ -34,7 +36,7 @@ class LineReferentialSync < ActiveRecord::Base
end
event :failed, after: :log_failed do
- transitions :from => :pending, :to => :failed
+ transitions :from => [:new, :pending], :to => :failed
end
end
diff --git a/app/models/stop_area_referential_sync.rb b/app/models/stop_area_referential_sync.rb
index 4de5f396a..a4e3eae30 100644
--- a/app/models/stop_area_referential_sync.rb
+++ b/app/models/stop_area_referential_sync.rb
@@ -6,6 +6,8 @@ class StopAreaReferentialSync < ActiveRecord::Base
after_commit :perform_sync, :on => :create
validate :multiple_process_validation, :on => :create
+ scope :pending, -> { where(status: [:new, :pending]) }
+
private
def perform_sync
create_sync_message :info, :new
@@ -26,7 +28,7 @@ class StopAreaReferentialSync < ActiveRecord::Base
state :failed
event :run, after: :log_pending do
- transitions :from => [:new, :failed], :to => :pending
+ transitions :from => :new, :to => :pending
end
event :successful, after: :log_successful do
diff --git a/app/workers/line_referential_sync_worker.rb b/app/workers/line_referential_sync_worker.rb
index b883e5180..df65fc10d 100644
--- a/app/workers/line_referential_sync_worker.rb
+++ b/app/workers/line_referential_sync_worker.rb
@@ -1,5 +1,7 @@
class LineReferentialSyncWorker
include Sidekiq::Worker
+ sidekiq_options :retry => false
+
def process_time
Process.clock_gettime(Process::CLOCK_MONOTONIC, :second)
end
diff --git a/app/workers/stop_area_referential_sync_worker.rb b/app/workers/stop_area_referential_sync_worker.rb
index f2c6746da..dede018dd 100644
--- a/app/workers/stop_area_referential_sync_worker.rb
+++ b/app/workers/stop_area_referential_sync_worker.rb
@@ -1,5 +1,6 @@
class StopAreaReferentialSyncWorker
include Sidekiq::Worker
+ sidekiq_options :retry => false
def process_time
Process.clock_gettime(Process::CLOCK_MONOTONIC, :second)
diff --git a/config/initializers/sidekiq.rb b/config/initializers/sidekiq.rb
new file mode 100644
index 000000000..52ec93250
--- /dev/null
+++ b/config/initializers/sidekiq.rb
@@ -0,0 +1,7 @@
+Sidekiq.configure_server do |config|
+ pendings = [
+ LineReferential.find_by(name: 'CodifLigne').line_referential_syncs.pending.take,
+ StopAreaReferential.find_by(name: 'Reflex').stop_area_referential_syncs.pending.take
+ ]
+ pendings.compact.map{|sync| sync.failed({error: 'Failed by Sidekiq reboot', processing_time: 0})}
+end