oysters 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/oysters/initd.rb +4 -2
- data/lib/oysters/templates/kewatcher_init.sh.erb +84 -0
- data/lib/oysters/templates/unicorn_init.sh.erb +42 -0
- data/lib/oysters/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8f1def3bc4dbe8a047ab6f8e1f2487913d74e881
|
4
|
+
data.tar.gz: f8b9843af9aad9cca0918b34c1c322a6c2804ee8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3436d14079022c6fa70ad39558a0fd7040672042acb4f32a4cd11c19e99351990f13573d5dc47e65d4e34d82333af252181f6b3238d87628644ddfe61f419fe7
|
7
|
+
data.tar.gz: f71e243f3b3fb6753fdee5f9b3bd84a6ce928b1115fd6876138ad0a25abf6ea55a89aaef878cafcbc7736bd9332cbbabed2898218ad4ec5c1ce191d7d654d22b
|
data/lib/oysters/initd.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'oysters'
|
2
|
+
require 'erb'
|
2
3
|
|
3
4
|
Oysters.with_configuration do
|
4
5
|
|
@@ -12,8 +13,9 @@ Oysters.with_configuration do
|
|
12
13
|
CapistranoUnicorn::Utility.send(:alias_method, :old_try_unicorn_user, :try_unicorn_user)
|
13
14
|
CapistranoUnicorn::Utility.send(:define_method, :try_unicorn_user, Proc.new { su_command })
|
14
15
|
run "mkdir -p #{shared_path}/config"
|
15
|
-
location =
|
16
|
+
location = File.expand_path('../templates/unicorn_init.sh.erb', __FILE__)
|
16
17
|
config = ERB.new(File.read(location))
|
18
|
+
puts config.result(binding)
|
17
19
|
text_config = config.result(binding)
|
18
20
|
text_config.gsub!(/(#{su_command}) (.*);/,'\1 "\2";')
|
19
21
|
put text_config, "#{shared_path}/config/#{application}_unicorn_init.sh"
|
@@ -87,7 +89,7 @@ Oysters.with_configuration do
|
|
87
89
|
desc 'Generate kewatcher init.d script'
|
88
90
|
task :setup, roles: :app do
|
89
91
|
run "mkdir -p #{shared_path}/config"
|
90
|
-
location =
|
92
|
+
location = File.expand_path('../templates/kewatcher_init.sh.erb', __FILE__)
|
91
93
|
config = ERB.new(File.read(location))
|
92
94
|
put config.result(binding), "#{shared_path}/config/#{application}_kewatcher_init.sh"
|
93
95
|
end
|
@@ -0,0 +1,84 @@
|
|
1
|
+
#!/bin/sh
|
2
|
+
# chkconfig: 345 99 55
|
3
|
+
# description: script to start <%= application %> kewatcher
|
4
|
+
# /etc/init.d/<%= application %>_kewatcher
|
5
|
+
|
6
|
+
start() {
|
7
|
+
if [ -e <%= shared_path %>/pids/kewatcher.pid ] && kill -0 `cat <%= shared_path %>/pids/kewatcher.pid` >/dev/null 2>&1; then
|
8
|
+
echo "Kewatcher is already running. Sending restart command..."
|
9
|
+
su - <%= user %> -c "kill -s HUP `cat <%= shared_path %>/pids/kewatcher.pid`"
|
10
|
+
else
|
11
|
+
echo "Kewatcher is not running. Executing start command..."
|
12
|
+
su - <%= user %> -c "cd <%= current_path %>; RAILS_ENV=<%= rails_env %> <%= fetch(:bundle_cmd, 'bundle') %> exec <%= current_path %>/bin/kewatcher -m <%= fetch(:kewatcher_max_workers, 130) %> -c <%= current_path %>/config/redis.yml -p <%= shared_path %>/pids/kewatcher.pid >/dev/null 2>&1 &"
|
13
|
+
tries_count=10
|
14
|
+
success=0
|
15
|
+
while [ $((tries_count-=1)) -ge 0 ]; do
|
16
|
+
if [[ -n `pgrep -xf "[K]EWatcher.*"` ]] >/dev/null 2>&1; then
|
17
|
+
success=1
|
18
|
+
break
|
19
|
+
fi
|
20
|
+
sleep 1
|
21
|
+
done
|
22
|
+
if [ $success -eq 0 ]; then
|
23
|
+
echo "***KEWatcher has failed to start. Please try again..."
|
24
|
+
else
|
25
|
+
echo "+++KEWatcher has been started successfully."
|
26
|
+
fi
|
27
|
+
fi
|
28
|
+
}
|
29
|
+
|
30
|
+
stop() {
|
31
|
+
if [ -e <%= shared_path %>/pids/kewatcher.pid ] && kill -0 `cat <%= shared_path %>/pids/kewatcher.pid` >/dev/null 2>&1; then
|
32
|
+
echo "Stopping Kewatcher..."
|
33
|
+
kill -s QUIT `cat <%= shared_path %>/pids/kewatcher.pid`
|
34
|
+
tries_count=50
|
35
|
+
success=0
|
36
|
+
while [ $((tries_count-=1)) -ge 0 ]; do
|
37
|
+
if [[ -n `pgrep -xf "[K]EWatcher.*|[r]esque-[0-9]+.*"` ]] >/dev/null 2>&1; then
|
38
|
+
sleep 1
|
39
|
+
else
|
40
|
+
success=1
|
41
|
+
break
|
42
|
+
fi
|
43
|
+
done
|
44
|
+
if [ $success -eq 0 ]; then
|
45
|
+
pidkewat=`pgrep -xf [K]EWatcher.*`
|
46
|
+
if [[ -n $pidkewat ]] >/dev/null 2>&1; then
|
47
|
+
echo "~~~KEWatcher has failed to stop. So kill pid=$pidkewat ..."
|
48
|
+
kill -s KILL `cat <%= shared_path %>/pids/kewatcher.pid`
|
49
|
+
rm -f <%= shared_path %>/pids/kewatcher.pid
|
50
|
+
echo "~~~ killing workers as well"
|
51
|
+
kill -s KILL `pgrep -xf "[r]esque-[0-9]+.*" | xargs`
|
52
|
+
else
|
53
|
+
echo "***KEWatcher has been stopped. But some workers still running. Kill'em all..."
|
54
|
+
kill -s KILL `pgrep -xf "[r]esque-[0-9]+.*" | xargs`
|
55
|
+
fi
|
56
|
+
else
|
57
|
+
echo "+++KEWatcher has been stopped successfully."
|
58
|
+
fi
|
59
|
+
sleep 1
|
60
|
+
else
|
61
|
+
echo "Kewatcher is not running."
|
62
|
+
fi
|
63
|
+
}
|
64
|
+
|
65
|
+
case "$1" in
|
66
|
+
start)
|
67
|
+
echo "calling ${1} on <%= application %> Kewatcher ... "
|
68
|
+
start
|
69
|
+
;;
|
70
|
+
stop)
|
71
|
+
echo "calling ${1} on <%= application %> Kewatcher ... "
|
72
|
+
stop
|
73
|
+
;;
|
74
|
+
restart)
|
75
|
+
echo "calling ${1} on <%= application %> Kewatcher ... "
|
76
|
+
stop
|
77
|
+
start
|
78
|
+
;;
|
79
|
+
*)
|
80
|
+
echo "Usage: $0 {start|stop|restart}"
|
81
|
+
exit 1
|
82
|
+
esac
|
83
|
+
|
84
|
+
exit $?
|
@@ -0,0 +1,42 @@
|
|
1
|
+
#!/bin/bash
|
2
|
+
# chkconfig: 345 99 55
|
3
|
+
# description: script to start <%= application %> unicorn
|
4
|
+
# /etc/init.d/<%= application %>_unicorn
|
5
|
+
|
6
|
+
start() {
|
7
|
+
<%= start_unicorn %>
|
8
|
+
}
|
9
|
+
|
10
|
+
stop() {
|
11
|
+
<%= kill_unicorn('QUIT') %>
|
12
|
+
sleep 5
|
13
|
+
<%= kill_unicorn('KILL') %>
|
14
|
+
}
|
15
|
+
|
16
|
+
restart_unicorn() {
|
17
|
+
<%= duplicate_unicorn %>
|
18
|
+
sleep <%= unicorn_restart_sleep_time %> # in order to wait for the (old) pidfile to show up
|
19
|
+
if <%= old_unicorn_is_running? %>; then
|
20
|
+
<%= unicorn_send_signal('QUIT', get_old_unicorn_pid) %>;
|
21
|
+
fi
|
22
|
+
}
|
23
|
+
|
24
|
+
case "$1" in
|
25
|
+
start)
|
26
|
+
echo "calling ${1} on <%= application %> Unicorn ... "
|
27
|
+
start
|
28
|
+
;;
|
29
|
+
stop)
|
30
|
+
echo "calling ${1} on <%= application %> Unicorn ... "
|
31
|
+
stop
|
32
|
+
;;
|
33
|
+
restart)
|
34
|
+
echo "calling ${1} on <%= application %> Unicorn ... "
|
35
|
+
restart_unicorn
|
36
|
+
;;
|
37
|
+
*)
|
38
|
+
echo "Usage: $0 {start|stop|restart}"
|
39
|
+
exit 1
|
40
|
+
esac
|
41
|
+
|
42
|
+
exit $?
|
data/lib/oysters/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: oysters
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Roman Samoilov
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-03-
|
11
|
+
date: 2015-03-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -71,6 +71,8 @@ files:
|
|
71
71
|
- lib/oysters/initd.rb
|
72
72
|
- lib/oysters/resque_scheduler.rb
|
73
73
|
- lib/oysters/resque_sliders.rb
|
74
|
+
- lib/oysters/templates/kewatcher_init.sh.erb
|
75
|
+
- lib/oysters/templates/unicorn_init.sh.erb
|
74
76
|
- lib/oysters/version.rb
|
75
77
|
- oysters.gemspec
|
76
78
|
homepage: https://github.com/rsamoilov/oysters
|