mirror of
https://0xacab.org/sutty/sutty
synced 2024-11-13 06:41:42 +00:00
monitorear
This commit is contained in:
parent
6d3b2dac16
commit
d489ef0bf2
9 changed files with 32 additions and 23 deletions
|
@ -111,6 +111,8 @@ USER root
|
|||
RUN install -m 755 /srv/http/sync_assets.sh /usr/local/bin/sync_assets
|
||||
# Instalar la configuración de monit
|
||||
RUN install -m 640 -o root -g root /srv/http/monit.conf /etc/monit.d/sutty.conf
|
||||
RUN apk add --no-cache daemonize
|
||||
RUN install -m 755 /srv/http/prometheus.sh /usr/local/bin/prometheus
|
||||
|
||||
# Mantener estos directorios!
|
||||
VOLUME "/srv/http/data"
|
||||
|
|
1
Gemfile
1
Gemfile
|
@ -78,6 +78,7 @@ gem 'flamegraph'
|
|||
gem 'memory_profiler'
|
||||
gem 'rack-mini-profiler'
|
||||
gem 'stackprof'
|
||||
gem 'prometheus_exporter'
|
||||
|
||||
group :themes do
|
||||
gem 'adhesiones-jekyll-theme', require: false
|
||||
|
|
10
Gemfile.lock
10
Gemfile.lock
|
@ -205,7 +205,7 @@ GEM
|
|||
http_parser.rb (0.6.0)
|
||||
i18n (1.8.5)
|
||||
concurrent-ruby (~> 1.0)
|
||||
icalendar (2.6.1)
|
||||
icalendar (2.7.0)
|
||||
ice_cube (~> 0.16)
|
||||
ice_cube (0.16.3)
|
||||
image_processing (1.11.0)
|
||||
|
@ -214,7 +214,7 @@ GEM
|
|||
inline_svg (1.7.1)
|
||||
activesupport (>= 3.0)
|
||||
nokogiri (>= 1.6)
|
||||
jbuilder (2.10.0)
|
||||
jbuilder (2.10.1)
|
||||
activesupport (>= 5.0.0)
|
||||
jekyll (4.1.1)
|
||||
addressable (~> 2.4)
|
||||
|
@ -309,6 +309,7 @@ GEM
|
|||
forwardable-extended (~> 2.6)
|
||||
pg (1.2.3)
|
||||
popper_js (1.16.0)
|
||||
prometheus_exporter (0.5.3)
|
||||
pry (0.13.1)
|
||||
coderay (~> 1.1)
|
||||
method_source (~> 1.0)
|
||||
|
@ -405,7 +406,7 @@ GEM
|
|||
rubocop-ast (>= 0.3.0, < 1.0)
|
||||
ruby-progressbar (~> 1.7)
|
||||
unicode-display_width (>= 1.4.0, < 2.0)
|
||||
rubocop-ast (0.3.0)
|
||||
rubocop-ast (0.4.0)
|
||||
parser (>= 2.7.1.4)
|
||||
rubocop-rails (2.8.0)
|
||||
activesupport (>= 4.2.0)
|
||||
|
@ -453,7 +454,7 @@ GEM
|
|||
sprockets (4.0.2)
|
||||
concurrent-ruby (~> 1.0)
|
||||
rack (> 1, < 3)
|
||||
sprockets-rails (3.2.1)
|
||||
sprockets-rails (3.2.2)
|
||||
actionpack (>= 4.0)
|
||||
activesupport (>= 4.0)
|
||||
sprockets (>= 3.0.0)
|
||||
|
@ -565,6 +566,7 @@ DEPENDENCIES
|
|||
minima
|
||||
mobility
|
||||
pg
|
||||
prometheus_exporter
|
||||
pry
|
||||
puma
|
||||
pundit
|
||||
|
|
1
Procfile
1
Procfile
|
@ -4,3 +4,4 @@ blazer_5m: bundle exec rake blazer:run_checks SCHEDULE="5 minutes"
|
|||
blazer_1h: bundle exec rake blazer:run_checks SCHEDULE="1 hour"
|
||||
blazer_1d: bundle exec rake blazer:run_checks SCHEDULE="1 day"
|
||||
blazer: bundle exec rake blazer:send_failing_checks
|
||||
prometheus: bundle exec prometheus_exporter -b 0.0.0.0 --prefix "sutty_" -d
|
||||
|
|
6
config/initializers/prometheus.rb
Normal file
6
config/initializers/prometheus.rb
Normal file
|
@ -0,0 +1,6 @@
|
|||
unless Rails.env.test?
|
||||
require 'prometheus_exporter/middleware'
|
||||
|
||||
# This reports stats per request like HTTP status and timings
|
||||
Rails.application.middleware.unshift PrometheusExporter::Middleware
|
||||
end
|
|
@ -56,4 +56,9 @@ end
|
|||
#
|
||||
on_worker_boot do
|
||||
ActiveRecord::Base.establish_connection if defined?(ActiveRecord)
|
||||
|
||||
require 'prometheus_exporter/instrumentation'
|
||||
PrometheusExporter::Instrumentation::ActiveRecord.start(custom_labels: { type: 'puma_worker' }, config_labels: %i[database host])
|
||||
PrometheusExporter::Instrumentation::Puma.start
|
||||
PrometheusExporter::Instrumentation::Process.start(type: 'web')
|
||||
end
|
||||
|
|
|
@ -1,24 +1,6 @@
|
|||
#!/bin/sh
|
||||
set -e
|
||||
export RAILS_ENV=production
|
||||
|
||||
case $1 in
|
||||
rails)
|
||||
cd /srv/http
|
||||
bundle exec rake db:migrate
|
||||
bundle exec rake db:seed
|
||||
bundle exec puma -d config.ru
|
||||
exit $?
|
||||
;;
|
||||
darkhttpd)
|
||||
darkhttpd /srv/http/public \
|
||||
--no-server-id \
|
||||
--pidfile /tmp/darkhttpd.pid \
|
||||
--uid darkhttpd \
|
||||
--gid www-data \
|
||||
--no-listing \
|
||||
--daemon \
|
||||
--port 8080
|
||||
exit $?
|
||||
;;
|
||||
prometheus) daemonize -c /srv/http -p /tmp/prometheus.pid -l /tmp/prometheus.pid -u app /usr/bin/foreman start prometheus ;;
|
||||
esac
|
||||
|
|
|
@ -3,6 +3,10 @@ check process sutty with pidfile /srv/http/tmp/puma.pid
|
|||
as uid "app" and gid "www-data"
|
||||
stop program = "/bin/sh -c 'cat /srv/http/tmp/puma.pid | xargs kill'"
|
||||
|
||||
check process prometheus with pidfile /tmp/prometheus.pid
|
||||
start program = "/usr/local/bin/prometheus"
|
||||
stop program = "/bin/sh -c 'cat /tmp/prometheus.pid | xargs kill'"
|
||||
|
||||
check program sync_assets
|
||||
with path /usr/local/bin/sync_assets
|
||||
if status = 0 then unmonitor
|
||||
|
|
6
prometheus.sh
Executable file
6
prometheus.sh
Executable file
|
@ -0,0 +1,6 @@
|
|||
#!/bin/sh
|
||||
set -e
|
||||
|
||||
case $1 in
|
||||
prometheus) daemonize -c /srv/http -p /tmp/prometheus.pid -l /tmp/prometheus.pid -u app /usr/bin/foreman start prometheus ;;
|
||||
esac
|
Loading…
Reference in a new issue