oysters 1.2.1 → 1.2.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/logrotate.rb +3 -16
- data/lib/oysters/unified/initd.rb +9 -9
- data/lib/oysters/unified/scripts/kewatcher_initd_script.sh +32 -25
- data/lib/oysters/unified/scripts/resque_scheduler_initd_script.sh +21 -26
- data/lib/oysters/unified/scripts/unicorn_initd_script.sh +29 -28
- data/lib/oysters/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ea9eeda4ba076675b827f384b4a6d556627627ad
|
4
|
+
data.tar.gz: 8d5669b9d4f64d27d65cd25484d37478f29ba0ae
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 15da67a2b00ce7b9455166804cc6f1d2a3b748710ddf40f41da75aff0b1836c069066fa54a33842aeb5f7a425f74de4324cb8ef7f313ee244a9c8a526603cf7b
|
7
|
+
data.tar.gz: 6031b5ca3972e37aed3e297af21b3e2e5c0a1c71a96fe61c8744ab26491f03a84b4953c3eb0b532fe9e15f65b17a2ef6192181689b1cf0f85fe5523e57db43c5
|
@@ -7,29 +7,16 @@ Oysters.with_configuration do
|
|
7
7
|
namespace :logrotate do
|
8
8
|
desc 'Install logrotate config'
|
9
9
|
task :install, roles: :app do
|
10
|
-
log_path =
|
11
|
-
|
12
|
-
if application == 'oiv-ui'
|
13
|
-
%W(#{rails_env}_delayed_job.log #{rails_env}_security_audit.log unicorn_#{rails_env}.stderr.log skylight.log).each do |log|
|
14
|
-
log_path << Pathname.new(shared_path).join('log', log).to_s
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
if application == 'oiv-api'
|
19
|
-
%W(skylight.log).each do |log|
|
20
|
-
log_path << Pathname.new(shared_path).join('log', log).to_s
|
21
|
-
end
|
22
|
-
end
|
10
|
+
log_path = Pathname.new(shared_path).join('log', "*.log").to_s
|
23
11
|
|
24
12
|
conf_path = "/etc/logrotate.d/#{application}_logs"
|
25
|
-
log_path = log_path.join(' ')
|
26
13
|
tmp_file = "/tmp/#{application}_logs_#{rand}"
|
27
14
|
location = File.expand_path('../../templates/logrotate_config.erb', __FILE__)
|
28
15
|
config = ERB.new(File.read(location))
|
29
16
|
|
30
17
|
put config.result(binding), tmp_file
|
31
|
-
sudo "mv #{tmp_file} #{conf_path}"
|
32
|
-
sudo "logrotate #{conf_path}"
|
18
|
+
sudo "mv #{tmp_file} #{conf_path}", pty: true, shell: :bash
|
19
|
+
sudo "logrotate #{conf_path}", pty: true, shell: :bash
|
33
20
|
end
|
34
21
|
end
|
35
22
|
|
@@ -15,22 +15,22 @@ Oysters.with_configuration do
|
|
15
15
|
task :install, roles: :app do
|
16
16
|
tmp_config_path = "/tmp/#{program}_initd_script.sh"
|
17
17
|
# Remove old tmp config if present
|
18
|
-
|
18
|
+
sudo "rm -f #{tmp_config_path}", pty: true, shell: :bash
|
19
19
|
|
20
20
|
config = File.read(File.expand_path("../scripts/#{program}_initd_script.sh", __FILE__))
|
21
21
|
put config, tmp_config_path, shell: :bash
|
22
22
|
|
23
|
-
|
24
|
-
|
25
|
-
|
23
|
+
sudo "cp #{tmp_config_path} /etc/init.d/#{application}_#{program}", pty: true, shell: :bash
|
24
|
+
sudo "chmod +x /etc/init.d/#{application}_#{program}", pty: true, shell: :bash
|
25
|
+
sudo "chkconfig --add #{application}_#{program}", pty: true, shell: :bash
|
26
26
|
run "rm -f #{tmp_config_path}", shell: :bash
|
27
27
|
end
|
28
28
|
|
29
29
|
#Run this task as a sudo user!
|
30
30
|
desc "Remove #{program} init.d script"
|
31
31
|
task :uninstall, roles: :app do
|
32
|
-
|
33
|
-
|
32
|
+
sudo "chkconfig --del #{application}_#{program}", pty: true, shell: :bash
|
33
|
+
sudo "rm -f /etc/init.d/#{application}_#{program}", pty: true, shell: :bash
|
34
34
|
end
|
35
35
|
end
|
36
36
|
end
|
@@ -45,20 +45,20 @@ Oysters.with_configuration do
|
|
45
45
|
task :install, roles: :app do
|
46
46
|
tmp_config_path = "/tmp/deployed_application_sysconfig.sh"
|
47
47
|
# Remove old tmp config if present
|
48
|
-
|
48
|
+
sudo "rm -f #{tmp_config_path}", pty: true, shell: :bash
|
49
49
|
|
50
50
|
location = File.expand_path('../templates/app_sysconfig.sh.erb', __FILE__)
|
51
51
|
config = ERB.new(File.read(location))
|
52
52
|
put config.result(binding), tmp_config_path, shell: :bash
|
53
53
|
|
54
|
-
|
54
|
+
sudo "cp #{tmp_config_path} /etc/sysconfig/deployed_application", pty: true, shell: :bash
|
55
55
|
run "rm -f #{tmp_config_path}", shell: :bash
|
56
56
|
end
|
57
57
|
|
58
58
|
#Run this task as a sudo user!
|
59
59
|
desc 'Remove sysconfig'
|
60
60
|
task :uninstall, roles: :app do
|
61
|
-
|
61
|
+
sudo "rm -f /etc/sysconfig/deployed_application", pty: true, shell: :bash
|
62
62
|
end
|
63
63
|
end
|
64
64
|
|
@@ -13,55 +13,62 @@ start() {
|
|
13
13
|
local program
|
14
14
|
local options
|
15
15
|
|
16
|
-
echo "Starting KEWatcher"
|
17
16
|
if [ -e $KEWATCHER_PIDFILE ] && kill -0 `cat $KEWATCHER_PIDFILE` > /dev/null 2>&1; then
|
18
17
|
echo "KEWatcher is already Running"
|
19
|
-
echo_success
|
20
18
|
return 0
|
21
19
|
fi
|
22
20
|
|
21
|
+
cd $ROOT_PATH
|
22
|
+
|
23
|
+
env_vars="RAILS_ENV=$RAILS_ENV"
|
23
24
|
options="-m $KEWATCHER_MAX_WORKERS -c $KEWATCHER_REDIS_CONFIG -p $KEWATCHER_PIDFILE $KEWATCHER_VERBOSE"
|
25
|
+
program="source /home/$APP_USER/.bash_profile; $env_vars bundle exec $ROOT_PATH/bin/kewatcher $options 2>&1 >> $KEWATCHER_LOGFILE &"
|
24
26
|
|
25
|
-
|
26
|
-
RETVAL=$?
|
27
|
+
action 'Starting KEWatcher...' daemon --user "${APP_USER#$USER}" --pidfile=$KEWATCHER_PIDFILE $program
|
27
28
|
|
29
|
+
# workaround to allow KEWatcher to setup a trap for HUP signal
|
28
30
|
sleep 5
|
29
|
-
|
30
|
-
if [ $RETVAL -eq 0 ]; then
|
31
|
-
echo_success
|
32
|
-
else
|
33
|
-
echo_failure
|
34
|
-
fi
|
35
|
-
echo
|
36
31
|
}
|
37
32
|
|
38
33
|
stop() {
|
39
|
-
echo "Stopping KEWatcher"
|
40
|
-
|
41
34
|
if [ -f $KEWATCHER_PIDFILE ]; then
|
42
|
-
|
43
|
-
|
44
|
-
|
35
|
+
# The idea is to let KEWatcher to gracefully stop,
|
36
|
+
# wait with delay gives us dynamic wait interval
|
37
|
+
# limited by N tries.
|
38
|
+
|
39
|
+
action 'Stopping KEWatcher...' _stop_with_wait $(cat $KEWATCHER_PIDFILE)
|
45
40
|
else
|
46
|
-
|
41
|
+
echo "Resque KEWatcher is not running"
|
47
42
|
fi
|
48
43
|
|
49
|
-
echo
|
44
|
+
echo 'Killing stuck workers...'
|
50
45
|
kill -s KILL `pgrep -xf "[r]esque-[0-9]+.*" | xargs` > /dev/null 2>&1
|
51
46
|
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
47
|
+
rm -f $KEWATCHER_PIDFILE
|
48
|
+
}
|
49
|
+
|
50
|
+
_stop_with_wait() {
|
51
|
+
local pid delay tries try
|
52
|
+
|
53
|
+
delay=10
|
54
|
+
tries=3
|
55
|
+
pid=$1
|
56
|
+
try=0
|
57
|
+
|
58
|
+
kill -s QUIT $pid
|
59
|
+
|
60
|
+
while [ $try -lt $tries ] ; do
|
61
|
+
checkpid $pid || return 0
|
62
|
+
sleep $delay
|
63
|
+
let try+=1
|
64
|
+
done
|
58
65
|
}
|
59
66
|
|
60
67
|
case "$1" in
|
61
68
|
start) start ;;
|
62
69
|
stop) stop ;;
|
63
70
|
restart)
|
64
|
-
echo "Restarting Resque KEWatcher
|
71
|
+
echo "Restarting Resque KEWatcher..."
|
65
72
|
stop
|
66
73
|
start
|
67
74
|
;;
|
@@ -15,42 +15,38 @@ start() {
|
|
15
15
|
|
16
16
|
cd $ROOT_PATH
|
17
17
|
|
18
|
-
echo "Starting Resque Scheduler"
|
19
18
|
options="RAILS_ENV=$RAILS_ENV VERBOSE=$SCHEDULER_VERBOSE BACKGROUND=$BACKGROUND DYNAMIC_SCHEDULE=$DYNAMIC_SCHEDULE PIDFILE=$SCHEDULER_PIDFILE"
|
20
19
|
program="source /home/$APP_USER/.bash_profile; bundle exec rake resque:scheduler $options 2>&1 >> $SCHEDULER_LOGFILE"
|
21
20
|
|
22
|
-
|
23
|
-
then
|
24
|
-
daemon --pidfile=$SCHEDULER_PIDFILE $program
|
25
|
-
else
|
26
|
-
daemon --user $APP_USER --pidfile=$SCHEDULER_PIDFILE $program
|
27
|
-
fi
|
28
|
-
RETVAL=$?
|
21
|
+
action 'Starting Resque Scheduler...' daemon --user "${APP_USER#$USER}" --pidfile=$SCHEDULER_PIDFILE $program
|
29
22
|
|
30
|
-
|
31
|
-
|
32
|
-
else
|
33
|
-
echo_failure
|
34
|
-
fi
|
35
|
-
echo
|
23
|
+
# workaround to allow Resque Scheduler to setup a trap for HUP signal
|
24
|
+
sleep 5
|
36
25
|
}
|
37
26
|
|
38
27
|
stop() {
|
39
|
-
echo "Stopping Resque Scheduler"
|
40
|
-
|
41
28
|
if [ -f $SCHEDULER_PIDFILE ]; then
|
42
|
-
|
43
|
-
RETVAL=$?
|
29
|
+
action 'Stopping Resque Scheduler...' _stop_with_wait $(cat $SCHEDULER_PIDFILE)
|
44
30
|
else
|
45
|
-
|
31
|
+
echo 'Resque Scheduler is not running'
|
46
32
|
fi
|
33
|
+
}
|
47
34
|
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
35
|
+
_stop_with_wait() {
|
36
|
+
local pid delay tries try
|
37
|
+
|
38
|
+
delay=2
|
39
|
+
tries=3
|
40
|
+
pid=$1
|
41
|
+
try=0
|
42
|
+
|
43
|
+
kill -s QUIT $pid
|
44
|
+
|
45
|
+
while [ $try -lt $tries ] ; do
|
46
|
+
checkpid $pid || return 0
|
47
|
+
sleep $delay
|
48
|
+
let try+=1
|
49
|
+
done
|
54
50
|
}
|
55
51
|
|
56
52
|
case "$1" in
|
@@ -59,7 +55,6 @@ case "$1" in
|
|
59
55
|
restart)
|
60
56
|
echo "Restarting Resque scheduler ... "
|
61
57
|
stop
|
62
|
-
sleep 2
|
63
58
|
start
|
64
59
|
;;
|
65
60
|
*)
|
@@ -16,54 +16,55 @@ start() {
|
|
16
16
|
|
17
17
|
cd $ROOT_PATH
|
18
18
|
|
19
|
-
echo "Starting Unicorn"
|
20
19
|
env_vars="RAILS_ENV=$RAILS_ENV BUNDLE_GEMFILE=$BUNDLE_GEMFILE"
|
21
20
|
options="-c $UNICORN_CONFIG -E $RAILS_ENV -D "
|
22
21
|
program="source /home/$APP_USER/.bash_profile; $env_vars bundle exec unicorn $options"
|
23
22
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
fi
|
30
|
-
RETVAL=$?
|
23
|
+
action 'Starting Unicorn...' daemon --user "${APP_USER#$USER}" --pidfile=$UNICORN_PIDFILE $program
|
24
|
+
}
|
25
|
+
|
26
|
+
stop() {
|
27
|
+
local unicorn_pid
|
31
28
|
|
32
|
-
|
33
|
-
|
29
|
+
unicorn_pid=$(cat $UNICORN_PIDFILE)
|
30
|
+
|
31
|
+
if checkpid $unicorn_pid ; then
|
32
|
+
action 'Stopping Unicorn...' kill -s QUIT $unicorn_pid
|
34
33
|
else
|
35
|
-
|
34
|
+
echo "Unicorn is not running"
|
36
35
|
fi
|
37
|
-
echo
|
38
36
|
}
|
39
37
|
|
40
|
-
|
41
|
-
|
38
|
+
restart() {
|
39
|
+
local unicorn_pid restart_sleep
|
40
|
+
|
41
|
+
restart_sleep=5
|
42
|
+
|
43
|
+
echo "Restarting Unicorn..."
|
42
44
|
|
43
45
|
if [ -f $UNICORN_PIDFILE ]; then
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
RETVAL=1
|
48
|
-
fi
|
46
|
+
unicorn_pid=$(cat $UNICORN_PIDFILE)
|
47
|
+
|
48
|
+
action 'Clonning Master...' kill -s USR2 $unicorn_pid
|
49
49
|
|
50
|
-
|
51
|
-
|
50
|
+
[ "${?}" -ne 0 ] && return $?
|
51
|
+
|
52
|
+
sleep $restart_sleep
|
53
|
+
|
54
|
+
if checkpid $unicorn_pid ; then
|
55
|
+
action 'Killing old Master...' kill -s QUIT $unicorn_pid
|
56
|
+
fi
|
52
57
|
else
|
53
58
|
echo "Unicorn is not running"
|
59
|
+
start
|
60
|
+
return $?
|
54
61
|
fi
|
55
|
-
echo_success
|
56
62
|
}
|
57
63
|
|
58
64
|
case "$1" in
|
59
65
|
start) start ;;
|
60
66
|
stop) stop ;;
|
61
|
-
restart)
|
62
|
-
echo "Restarting Unicorn ... "
|
63
|
-
stop
|
64
|
-
sleep 5
|
65
|
-
start
|
66
|
-
;;
|
67
|
+
restart) restart ;;
|
67
68
|
*)
|
68
69
|
echo "Usage: $0 {start|stop|restart}"
|
69
70
|
exit 1
|
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: 1.2.
|
4
|
+
version: 1.2.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: 2016-
|
11
|
+
date: 2016-08-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -110,7 +110,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
110
110
|
version: '0'
|
111
111
|
requirements: []
|
112
112
|
rubyforge_project:
|
113
|
-
rubygems_version: 2.
|
113
|
+
rubygems_version: 2.5.1
|
114
114
|
signing_key:
|
115
115
|
specification_version: 4
|
116
116
|
summary: Common capistrano recipes
|