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
d9832656
Commit
d9832656
authored
9 years ago
by
Jordan Hollinger
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add support for monit
parent
68d192b1
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
78 additions
and
0 deletions
+78
-0
README.md
+2
-0
lib/capistrano/sneakers/monit.rb
+2
-0
lib/capistrano/tasks/monit.rake
+67
-0
lib/capistrano/templates/sneakers_monit.conf.erb
+7
-0
No files found.
README.md
View file @
d9832656
...
...
@@ -25,6 +25,8 @@ Or install it yourself as:
# Capfile
require
'capistrano/sneakers'
# Include monit tasks
# require 'capistrano/sneakers/monit'
```
## Contributors
...
...
This diff is collapsed.
Click to expand it.
lib/capistrano/sneakers/monit.rb
0 → 100644
View file @
d9832656
# Load monit tasks
load
File
.
expand_path
(
'../../tasks/monit.rake'
,
__FILE__
)
This diff is collapsed.
Click to expand it.
lib/capistrano/tasks/monit.rake
0 → 100644
View file @
d9832656
namespace
:load
do
task
:defaults
do
set
:sneakers_monit_conf_dir
,
->
{
"/etc/monit/conf.d/
#{
sneakers_monit_service_name
}
.conf"
}
set
:sneakers_monit_use_sudo
,
true
set
:sneakers_monit_bin
,
'/usr/bin/monit'
end
end
namespace
:sneakers
do
namespace
:monit
do
desc
'Add Sneakers to monit'
task
:config
do
on
roles
(
fetch
(
:sneakers_role
))
do
|
role
|
@role
=
role
template_sneakers
'sneakers_monit.conf'
,
"
#{
fetch
(
:tmp_dir
)
}
/monit.conf"
,
@role
sudo_if_needed
"mv
#{
fetch
(
:tmp_dir
)
}
/monit.conf
#{
fetch
(
:sneakers_monit_conf_dir
)
}
"
sudo_if_needed
"
#{
fetch
(
:sneakers_monit_bin
)
}
reload"
end
end
desc
'Enable Sneakers monit'
task
:monitor
do
on
roles
(
fetch
(
:sneakers_role
))
do
sudo_if_needed
"
#{
fetch
(
:sneakers_monit_bin
)
}
monitor
#{
sneakers_monit_service_name
}
"
end
end
desc
'Disable Sneakers monit'
task
:unmonitor
do
on
roles
(
fetch
(
:sneakers_role
))
do
sudo_if_needed
"
#{
fetch
(
:sneakers_monit_bin
)
}
unmonitor
#{
sneakers_monit_service_name
}
"
end
end
desc
'Start Sneakers through monit'
task
:start
do
on
roles
(
fetch
(
:sneakers_role
))
do
sudo_if_needed
"
#{
fetch
(
:sneakers_monit_bin
)
}
start
#{
sneakers_monit_service_name
}
"
end
end
desc
'Stop Sneakers through monit'
task
:stop
do
on
roles
(
fetch
(
:sneakers_role
))
do
sudo_if_needed
"
#{
fetch
(
:sneakers_monit_bin
)
}
stop
#{
sneakers_monit_service_name
}
"
end
end
desc
'Restart Sneakers through monit'
task
:restart
do
on
roles
(
fetch
(
:sneakers_role
))
do
sudo_if_needed
"
#{
fetch
(
:sneakers_monit_bin
)
}
restart
#{
sneakers_monit_service_name
}
"
end
end
before
'deploy:updating'
,
'sneakers:monit:unmonitor'
after
'deploy:published'
,
'sneakers:monit:monitor'
def
sneakers_monit_service_name
fetch
(
:sneakers_monit_service_name
,
"sneakers_
#{
fetch
(
:application
)
}
_
#{
fetch
(
:stage
)
}
"
)
end
def
sudo_if_needed
(
command
)
fetch
(
:sneakers_monit_use_sudo
)
?
sudo
(
command
)
:
execute
(
command
)
end
end
end
This diff is collapsed.
Click to expand it.
lib/capistrano/templates/sneakers_monit.conf.erb
0 → 100644
View file @
d9832656
# Monit configuration for Sneakers
# Service name:
<%=
sneakers_monit_service_name
%>
#
check process
<%=
sneakers_monit_service_name
%>
with pidfile "
<%=
fetch
(
:sneakers_pid
)
%>
"
start program = "/usr/bin/sudo -iu
<%=
sneakers_user
(
@role
)
%>
/bin/bash -c 'cd
<%=
current_path
%>
&&
RAILS_ENV=
<%=
fetch
(
:sneakers_env
)
%>
WORKERS=
<%=
fetch
(
:sneakers_workers
).
join
(
','
)
%>
<%=
SSHKit
.
config
.
command_map
[
:rake
]
%>
sneakers:run'"
stop program = "/usr/bin/sudo -iu
<%=
sneakers_user
(
@role
)
%>
/bin/bash -c 'kill -SIGTERM `cat
<%=
fetch
(
:sneakers_pid
)
%>
`'"
This diff is collapsed.
Click to expand it.
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