This repository is private.
All pages are served over SSL and all pushing and pulling is done over SSH.
No one may fork, clone, or view it unless they are added as a member.
Every repository with this icon (
) is private.
Every repository with this icon (
This repository is public.
Anyone may fork, clone, or view it.
Every repository with this icon (
) is public.
Every repository with this icon (
commit 1e90d63f9139f6bc5dc7624ef07076bedcbb0bb3
tree 1d29c169bc56e3ecc1513904ef35311aea58fbd0
parent 4d224bd3fe0824387da3cbb5390a02a8bd775c28
tree 1d29c169bc56e3ecc1513904ef35311aea58fbd0
parent 4d224bd3fe0824387da3cbb5390a02a8bd775c28
| 86ca18a9 » | macournoyer | 2008-02-05 | 1 | # == God config file | |
| 2 | # http://god.rubyforge.org/ | ||||
| 429ddd75 » | macournoyer | 2008-02-14 | 3 | # Authors: Gump and michael@glauche.de | |
| 86ca18a9 » | macournoyer | 2008-02-05 | 4 | # | |
| 5 | # Config file for god that configures watches for each instance of a thin server for | ||||
| 6 | # each thin configuration file found in /etc/thin. | ||||
| 7 | # In order to get it working on Ubuntu, I had to make a change to god as noted at | ||||
| 8 | # the following blog: | ||||
| 9 | # http://blog.alexgirard.com/2007/10/25/ruby-one-line-to-save-god/ | ||||
| 10 | # | ||||
| 11 | require 'yaml' | ||||
| 1a226855 » | macournoyer | 2008-01-09 | 12 | ||
| 86ca18a9 » | macournoyer | 2008-02-05 | 13 | config_path = "/etc/thin" | |
| 1a226855 » | macournoyer | 2008-01-09 | 14 | ||
| 86ca18a9 » | macournoyer | 2008-02-05 | 15 | Dir[config_path + "/*.yml"].each do |file| | |
| 16 | config = YAML.load_file(file) | ||||
| 17 | num_servers = config["servers"] ||= 1 | ||||
| 1a226855 » | macournoyer | 2008-01-09 | 18 | ||
| 429ddd75 » | macournoyer | 2008-02-14 | 19 | (0...num_servers).each do |i| | |
| 20 | # UNIX socket cluster use number 0 to 2 (for 3 servers) | ||||
| 21 | # and tcp cluster use port number 3000 to 3002. | ||||
| 22 | number = config['socket'] ? i : (config['port'] + i) | ||||
| 23 | |||||
| 86ca18a9 » | macournoyer | 2008-02-05 | 24 | God.watch do |w| | |
| 25 | w.group = "thin-" + File.basename(file, ".yml") | ||||
| 429ddd75 » | macournoyer | 2008-02-14 | 26 | w.name = w.group + "-#{number}" | |
| 86ca18a9 » | macournoyer | 2008-02-05 | 27 | ||
| 28 | w.interval = 30.seconds | ||||
| 29 | |||||
| 30 | w.uid = config["user"] | ||||
| 31 | w.gid = config["group"] | ||||
| 32 | |||||
| 429ddd75 » | macournoyer | 2008-02-14 | 33 | w.start = "thin start -C #{file} -o #{number}" | |
| 86ca18a9 » | macournoyer | 2008-02-05 | 34 | w.start_grace = 10.seconds | |
| 35 | |||||
| 429ddd75 » | macournoyer | 2008-02-14 | 36 | w.stop = "thin stop -C #{file} -o #{number}" | |
| 86ca18a9 » | macournoyer | 2008-02-05 | 37 | w.stop_grace = 10.seconds | |
| 38 | |||||
| 429ddd75 » | macournoyer | 2008-02-14 | 39 | w.restart = "thin restart -C #{file} -o #{number}" | |
| 86ca18a9 » | macournoyer | 2008-02-05 | 40 | ||
| 41 | pid_path = config["chdir"] + "/" + config["pid"] | ||||
| 42 | ext = File.extname(pid_path) | ||||
| 43 | |||||
| 429ddd75 » | macournoyer | 2008-02-14 | 44 | w.pid_file = pid_path.gsub(/#{ext}$/, ".#{number}#{ext}") | |
| 86ca18a9 » | macournoyer | 2008-02-05 | 45 | ||
| 46 | w.behavior(:clean_pid_file) | ||||
| 47 | |||||
| 48 | w.start_if do |start| | ||||
| 49 | start.condition(:process_running) do |c| | ||||
| 50 | c.interval = 5.seconds | ||||
| 51 | c.running = false | ||||
| 52 | end | ||||
| 53 | end | ||||
| 54 | |||||
| 55 | w.restart_if do |restart| | ||||
| 56 | restart.condition(:memory_usage) do |c| | ||||
| 57 | c.above = 150.megabytes | ||||
| 58 | c.times = [3,5] # 3 out of 5 intervals | ||||
| 59 | end | ||||
| 60 | |||||
| 61 | restart.condition(:cpu_usage) do |c| | ||||
| 62 | c.above = 50.percent | ||||
| 63 | c.times = 5 | ||||
| 64 | end | ||||
| 65 | end | ||||
| 66 | |||||
| 67 | w.lifecycle do |on| | ||||
| 68 | on.condition(:flapping) do |c| | ||||
| 69 | c.to_state = [:start, :restart] | ||||
| 70 | c.times = 5 | ||||
| 71 | c.within = 5.minutes | ||||
| 72 | c.transition = :unmonitored | ||||
| 73 | c.retry_in = 10.minutes | ||||
| 74 | c.retry_times = 5 | ||||
| 75 | c.retry_within = 2.hours | ||||
| 76 | end | ||||
| 77 | end | ||||
| 1a226855 » | macournoyer | 2008-01-09 | 78 | end | |
| 79 | end | ||||
| 80 | end | ||||








