Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
supports sidekiq livenessProbe
  • Loading branch information
kwhrtsk committed May 7, 2018
1 parent fdc111d commit d1d9d24
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 0 deletions.
5 changes: 5 additions & 0 deletions bin/health-check-sidekiq
@@ -0,0 +1,5 @@
#!/bin/bash -e

cd $(dirname $0)/..

./bin/rake sidekiq:status
5 changes: 5 additions & 0 deletions k8s/chart/templates/sidekiq-deploy.yaml
Expand Up @@ -30,6 +30,11 @@ spec:
imagePullPolicy: IfNotPresent
command:
- ./bin/start-sidekiq
livenessProbe:
exec:
command:
- ./bin/health-check-sidekiq
initialDelaySeconds: 30
envFrom:
- configMapRef:
name: {{ template "demoapp.rails-env.name" . }}
Expand Down
5 changes: 5 additions & 0 deletions k8s/manifests-step1/sidekiq-deploy.yaml
Expand Up @@ -25,6 +25,11 @@ spec:
imagePullPolicy: IfNotPresent
command:
- ./bin/start-sidekiq
livenessProbe:
exec:
command:
- ./bin/health-check-sidekiq
initialDelaySeconds: 30
envFrom:
- configMapRef:
name: demoapp-rails-env
Expand Down
5 changes: 5 additions & 0 deletions k8s/manifests-step2/sidekiq-deploy.yaml
Expand Up @@ -25,6 +25,11 @@ spec:
imagePullPolicy: IfNotPresent
command:
- ./bin/start-sidekiq
livenessProbe:
exec:
command:
- ./bin/health-check-sidekiq
initialDelaySeconds: 30
envFrom:
- configMapRef:
name: demoapp-rails-env
Expand Down
5 changes: 5 additions & 0 deletions k8s/manifests-step3/sidekiq-deploy.yaml
Expand Up @@ -25,6 +25,11 @@ spec:
imagePullPolicy: IfNotPresent
command:
- ./bin/start-sidekiq
livenessProbe:
exec:
command:
- ./bin/health-check-sidekiq
initialDelaySeconds: 30
envFrom:
- configMapRef:
name: demoapp-rails-env
Expand Down
5 changes: 5 additions & 0 deletions k8s/manifests-step4/sidekiq-deploy.yaml
Expand Up @@ -25,6 +25,11 @@ spec:
imagePullPolicy: IfNotPresent
command:
- ./bin/start-sidekiq
livenessProbe:
exec:
command:
- ./bin/health-check-sidekiq
initialDelaySeconds: 30
envFrom:
- configMapRef:
name: demoapp-rails-env
Expand Down
13 changes: 13 additions & 0 deletions lib/tasks/sidekiq.rake
@@ -0,0 +1,13 @@
namespace :sidekiq do
desc "Health check for sidekiq worker process."
task status: [:environment] do
require "socket"

hostname = Socket.gethostname
if Sidekiq::ProcessSet.new.any? { |ps| ps["hostname"] == hostname }
exit 0
else
exit 1
end
end
end

0 comments on commit d1d9d24

Please sign in to comment.