Skip to content
This repository has been archived by the owner on Jul 11, 2020. It is now read-only.

Commit

Permalink
collect background job stats
Browse files Browse the repository at this point in the history
dwradcliffe committed Mar 12, 2015
1 parent 86687e5 commit b70df9a
Showing 5 changed files with 34 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Berksfile.lock
Original file line number Diff line number Diff line change
@@ -207,7 +207,7 @@ GRAPH
rubygems-sensu (>= 0.0.0)
rubygems-ssh (>= 0.0.0)
rubygems-utility (>= 0.0.0)
rubygems-app (0.0.44)
rubygems-app (0.0.47)
apt (>= 0.0.0)
chef-vault (>= 0.0.0)
git (>= 0.0.0)
2 changes: 1 addition & 1 deletion cookbooks/rubygems-app/metadata.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name 'rubygems-app'

version '0.0.44'
version '0.0.47'

depends 'apt'
depends 'chef-vault'
14 changes: 14 additions & 0 deletions cookbooks/rubygems-app/recipes/delayed_job.rb
Original file line number Diff line number Diff line change
@@ -22,3 +22,17 @@
)
action ::File.exist?('/applications/rubygems/current') ? :enable : :disable
end

template '/usr/local/bin/background_job_stats.sh' do
source 'background_job_stats.sh.erb'
mode '0755'
owner 'root'
group 'root'
variables(host: node.chef_environment == 'production' ? 'rubygems.org' : 'staging.rubygems.org' )
end

cron 'background job stats collection' do
user 'root'
minute '*/1'
command '/usr/local/bin/background_job_stats.sh'
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash
set stats
for x in `curl -s -S -H "Host:<%= @host %>" http://localhost:3000/internal/background_job_stats`; do
key=${x%%=*}
key="delayed_job.$key"
value=${x##*=}
if [ -z "$stats" ]; then
stats="$key:$value|g"
else
stats="$stats\n$key:$value|g"
fi
done
echo -e -n "$stats" > /dev/udp/127.0.0.1/8125
5 changes: 5 additions & 0 deletions cookbooks/rubygems-app/templates/default/nginx.conf.erb
Original file line number Diff line number Diff line change
@@ -24,6 +24,11 @@ server {
# doc root
root <%= @rails_root %>/current/public;

location /internal/background_job_stats {
access_log off;
return 404;
}

# redirect not found error to the static page /404.html
error_page 404 @400_errors;
location @400_errors {

0 comments on commit b70df9a

Please sign in to comment.