Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
capistrano-sneakers
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ikcrm_common
capistrano-sneakers
Commits
146e66ca
Commit
146e66ca
authored
Aug 02, 2018
by
ErgoLau
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
prefix method name to isolate
parent
8f269a97
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
25 deletions
+25
-25
lib/capistrano/sneakers/helper_methods.rb
+6
-6
lib/capistrano/tasks/sneakers.rake
+19
-19
No files found.
lib/capistrano/sneakers/helper_methods.rb
View file @
146e66ca
module
Capistrano
module
Sneakers
module
HelperMethods
def
each_process_with_index
(
reverse
=
false
,
&
block
)
_pid_files
=
pid_files
def
sneakers_
each_process_with_index
(
reverse
=
false
,
&
block
)
_pid_files
=
sneakers_
pid_files
_pid_files
.
reverse!
if
reverse
_pid_files
.
each_with_index
do
|
pid_file
,
idx
|
within
release_path
do
...
...
@@ -11,7 +11,7 @@ module Capistrano
end
end
def
pid_files
def
sneakers_
pid_files
sneakers_roles
=
Array
(
fetch
(
:sneakers_roles
))
sneakers_roles
.
select!
{
|
role
|
host
.
roles
.
include?
(
role
)
}
sneakers_roles
.
flat_map
do
|
role
|
...
...
@@ -24,11 +24,11 @@ module Capistrano
end
end
def
pid_file_exists?
(
pid_file
)
def
sneakers_
pid_file_exists?
(
pid_file
)
test
(
*
(
"[ -f
#{
pid_file
}
]"
).
split
(
' '
))
end
def
process_exists?
(
pid_file
)
def
sneakers_
process_exists?
(
pid_file
)
test
(
*
(
"kill -0 $( cat
#{
pid_file
}
)"
).
split
(
' '
))
end
...
...
@@ -76,7 +76,7 @@ module Capistrano
end
end
def
switch_user
(
role
,
&
block
)
def
s
neakers_s
witch_user
(
role
,
&
block
)
user
=
sneakers_user
(
role
)
if
user
==
role
.
user
block
.
call
...
...
lib/capistrano/tasks/sneakers.rake
View file @
146e66ca
...
...
@@ -42,10 +42,10 @@ namespace :sneakers do
desc
'Quiet sneakers (stop processing new tasks)'
task
:quiet
do
on
roles
fetch
(
:sneakers_roles
)
do
|
role
|
switch_user
(
role
)
do
s
neakers_s
witch_user
(
role
)
do
if
test
(
"[ -d
#{
current_path
}
]"
)
each_process_with_index
(
true
)
do
|
pid_file
,
idx
|
if
pid_file_exists?
(
pid_file
)
&&
process_exists?
(
pid_file
)
sneakers_
each_process_with_index
(
true
)
do
|
pid_file
,
idx
|
if
pid_file_exists?
(
pid_file
)
&&
sneakers_
process_exists?
(
pid_file
)
quiet_sneakers
(
pid_file
)
end
end
...
...
@@ -57,10 +57,10 @@ namespace :sneakers do
desc
'Stop sneakers'
task
:stop
do
on
roles
fetch
(
:sneakers_roles
)
do
|
role
|
switch_user
(
role
)
do
s
neakers_s
witch_user
(
role
)
do
if
test
(
"[ -d
#{
current_path
}
]"
)
each_process_with_index
(
true
)
do
|
pid_file
,
idx
|
if
pid_file_exists?
(
pid_file
)
&&
process_exists?
(
pid_file
)
sneakers_
each_process_with_index
(
true
)
do
|
pid_file
,
idx
|
if
sneakers_pid_file_exists?
(
pid_file
)
&&
sneakers_
process_exists?
(
pid_file
)
stop_sneakers
(
pid_file
)
end
end
...
...
@@ -72,9 +72,9 @@ namespace :sneakers do
desc
'Start sneakers'
task
:start
do
on
roles
fetch
(
:sneakers_roles
)
do
|
role
|
switch_user
(
role
)
do
each_process_with_index
do
|
pid_file
,
idx
|
unless
pid_file_exists?
(
pid_file
)
&&
process_exists?
(
pid_file
)
s
neakers_s
witch_user
(
role
)
do
sneakers_
each_process_with_index
do
|
pid_file
,
idx
|
unless
sneakers_pid_file_exists?
(
pid_file
)
&&
sneakers_
process_exists?
(
pid_file
)
start_sneakers
(
pid_file
,
idx
)
end
end
...
...
@@ -94,9 +94,9 @@ namespace :sneakers do
desc
'Rolling-restart sneakers'
task
:rolling_restart
do
on
roles
fetch
(
:sneakers_roles
)
do
|
role
|
switch_user
(
role
)
do
each_process_with_index
(
true
)
do
|
pid_file
,
idx
|
if
pid_file_exists?
(
pid_file
)
&&
process_exists?
(
pid_file
)
s
neakers_s
witch_user
(
role
)
do
sneakers_
each_process_with_index
(
true
)
do
|
pid_file
,
idx
|
if
sneakers_pid_file_exists?
(
pid_file
)
&&
sneakers_
process_exists?
(
pid_file
)
stop_sneakers
(
pid_file
)
end
start_sneakers
(
pid_file
,
idx
)
...
...
@@ -108,10 +108,10 @@ namespace :sneakers do
# Delete any pid file not in use
task
:cleanup
do
on
roles
fetch
(
:sneakers_roles
)
do
|
role
|
switch_user
(
role
)
do
each_process_with_index
do
|
pid_file
,
idx
|
unless
process_exists?
(
pid_file
)
if
pid_file_exists?
(
pid_file
)
s
neakers_s
witch_user
(
role
)
do
sneakers_
each_process_with_index
do
|
pid_file
,
idx
|
unless
sneakers_
process_exists?
(
pid_file
)
if
sneakers_
pid_file_exists?
(
pid_file
)
execute
"rm
#{
pid_file
}
"
end
end
...
...
@@ -125,9 +125,9 @@ namespace :sneakers do
task
:respawn
do
invoke
'sneakers:cleanup'
on
roles
fetch
(
:sneakers_roles
)
do
|
role
|
switch_user
(
role
)
do
each_process_with_index
do
|
pid_file
,
idx
|
unless
pid_file_exists?
(
pid_file
)
s
neakers_s
witch_user
(
role
)
do
sneakers_
each_process_with_index
do
|
pid_file
,
idx
|
unless
sneakers_
pid_file_exists?
(
pid_file
)
start_sneakers
(
pid_file
,
idx
)
end
end
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment