repertoire-repertoire-devtools 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/README.txt +10 -1
  2. data/bin/postgresql_crontab_sweep +11 -9
  3. metadata +2 -1
data/README.txt CHANGED
@@ -5,8 +5,17 @@ Process management tools:
5
5
  - merb_persist: adaptation of Apple's mongrel_rails_persist launchd helper, for merb
6
6
  - postgresql_crontab_sweep: crontab like tasks for postgresql (esp. for full text indexing)
7
7
 
8
+ INSTALLING
9
+
8
10
  All are ruby applications; see individual files for more information. To install:
9
11
 
10
12
  sudo gem install repertoire-repertoire-devtools --source http://gems.github.com
11
13
 
12
- [ repetition in the gem name is not a typo - it's a side effect of github's gem naming system ]
14
+ [ repetition in the gem name is not a typo - it's a side effect of github's gem naming system ]
15
+
16
+
17
+ UPGRADING
18
+
19
+ [ postgresql_crontab_sweep ]
20
+ You will need to stop and delete any existing launchd tasks, then re-run postgresql_crontab_sweep install command.
21
+ This generates a lanchd plist that references the updated script file in your ruby gems repository.
@@ -53,21 +53,23 @@ require 'benchmark'
53
53
  # as default. You will need to grant this role to the superuser before this feature can be used, however.
54
54
  #
55
55
  # Christopher York 12/8/2008
56
+ # Revised CWY 6/2009 - removed fork to accomodate OS X launchd
56
57
  #
57
58
 
58
-
59
59
  def run(dbparams)
60
60
  # setup and connect
61
61
  cron_conn = PGconn.open(dbparams)
62
- forking = false
62
+ # forking = false
63
63
 
64
64
  # get the pending database cron tasks
65
65
  pending = cron_conn.exec("SELECT * FROM crontab WHERE last_updated_at + interval < now();")
66
66
 
67
67
  pending.each do |crontask|
68
68
  # fork a sub-process for each task, with its own database connection
69
- forking ||= true
70
- fork do
69
+ # CWY 6/2009: It turns out OS X 10.5 launchd hates forking, and erratically kills sub-processes
70
+ # For now, revised script not to fork for separate cron tasks
71
+ # forking ||= true
72
+ # fork do
71
73
  task_conn = PGconn.open(dbparams)
72
74
  begin
73
75
  # all postgresql cron tasks take place in their own transaction (which is the reason for this script - not possible in plpgsql)
@@ -85,12 +87,12 @@ def run(dbparams)
85
87
  task_conn.exec("UPDATE crontab SET failing = true, message = '#{ e.message }' WHERE id = #{ crontask['id'] }")
86
88
  end
87
89
  task_conn.close
88
- exit!
89
- end
90
+ # exit!
91
+ # end
90
92
  end
91
93
 
92
94
  cron_conn.close
93
- Process.wait if forking # avoid zombies by waiting for child processes to finish
95
+ # Process.wait if forking # avoid zombies by waiting for child processes to finish
94
96
  end
95
97
 
96
98
  def install(dbparams, script_args, sweep_interval)
@@ -133,7 +135,7 @@ END_OF_CREATE_TABLE
133
135
  h['Label'] = plist_label
134
136
  h['OnDemand'] = false
135
137
  h['ProgramArguments'] = [script_path, script_args.to_a].flatten.compact
136
- h['StartCalendarInterval'] = { 'StartInterval' => sweep_interval }
138
+ h['StartInterval'] = sweep_interval
137
139
 
138
140
  data = NSPropertyListSerialization.dataFromPropertyList_format_errorDescription(h, NSPropertyListXMLFormat_v1_0, nil)
139
141
  plist = NSString.alloc.initWithData_encoding(data, NSUTF8StringEncoding)
@@ -170,7 +172,7 @@ opts = {
170
172
  }
171
173
  args = {}
172
174
  installing = false
173
- sweep_interval = 5
175
+ sweep_interval = 30
174
176
 
175
177
  while opt = ARGV.shift
176
178
  case opt
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: repertoire-repertoire-devtools
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Christopher York
@@ -14,6 +14,7 @@ default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: ruby-pg
17
+ type: :runtime
17
18
  version_requirement:
18
19
  version_requirements: !ruby/object:Gem::Requirement
19
20
  requirements: