Changesets can be listed by changeset number.
The Git repository is here.
- Revision:
- 86
- Log:
Initial import of I2, an Instiki clone.
- Author:
- adh
- Date:
- Mon Oct 16 10:40:36 +0100 2006
- Size:
- 2276 Bytes
- Properties:
- Property svn:executable is set
1 | #!/usr/local/bin/ruby |
2 | |
3 | require 'optparse' |
4 | |
5 | def daemonize |
6 | exit if fork # Parent exits, child continues. |
7 | Process.setsid # Become session leader. |
8 | exit if fork # Zap session leader. See [1]. |
9 | Dir.chdir "/" # Release old working directory. |
10 | File.umask 0000 # Ensure sensible umask. Adjust as needed. |
11 | STDIN.reopen "/dev/null" # Free file descriptors and |
12 | STDOUT.reopen "/dev/null", "a" # point them somewhere sensible. |
13 | STDERR.reopen STDOUT # STDOUT/ERR should better go to a logfile. |
14 | end |
15 | |
16 | OPTIONS = { |
17 | :high_interval => 5.0, |
18 | :low_interval => 0.5, |
19 | :command => File.expand_path(File.dirname(__FILE__) + '/spawner'), |
20 | :daemon => false |
21 | } |
22 | |
23 | ARGV.options do |opts| |
24 | opts.banner = "Usage: spinner [options]" |
25 | |
26 | opts.separator "" |
27 | |
28 | opts.on <<-EOF |
29 | Description: |
30 | The spinner is a protection loop for the spawner, which will attempt to restart any FCGI processes |
31 | that might have been restarted or outright crashed. It's a brute-force attempt that'll just try |
32 | to run the spawner every X number of seconds, so it does pose a light load on the server. |
33 | |
34 | Examples: |
35 | spinner # attempts to run the spawner with default settings every second with output on the terminal |
36 | spinner -i 3 -d # only run the spawner every 3 seconds and detach from the terminal to become a daemon |
37 | spinner -c '/path/to/app/script/process/spawner -p 9000 -i 10' -d # using custom spawner |
38 | EOF |
39 | |
40 | opts.on(" Options:") |
41 | |
42 | opts.on("-c", "--command=path", String) { |OPTIONS[:command]| } |
43 | opts.on("-h", "--high-interval=seconds", Float) { |OPTIONS[:high_interval]| } |
44 | opts.on("-l", "--low-interval=seconds", Float) { |OPTIONS[:low_interval]| } |
45 | opts.on("-d", "--daemon") { |OPTIONS[:daemon]| } |
46 | |
47 | opts.separator "" |
48 | |
49 | opts.on("-h", "--help", "Show this help message.") { puts opts; exit } |
50 | |
51 | opts.parse! |
52 | end |
53 | |
54 | daemonize if OPTIONS[:daemon] |
55 | |
56 | trap(OPTIONS[:daemon] ? "TERM" : "INT") { exit } |
57 | trap("USR1") do |
58 | $interval = ($interval == OPTIONS[:high_interval] ? OPTIONS[:low_interval] : OPTIONS[:high_interval]) |
59 | puts "New interval: #{$interval}" |
60 | end |
61 | |
62 | $interval = OPTIONS[:high_interval] |
63 | |
64 | loop do |
65 | system(OPTIONS[:command]) |
66 | sleep($interval) |
67 | end |