rake_server 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -18,8 +18,33 @@ needing to load the application environment from scratch each time a task is
18
18
  executed. It may also be useful for remote invocation of Rake tasks, but that is
19
19
  not the main goal.
20
20
 
21
- === How do I use it?
21
+ === Basic usage
22
22
 
23
23
  $ cd /path/to/my/rails/app
24
- $ rake-server environment
24
+ $ rake-server start environment
25
25
  $ rake-client db:migrate
26
+
27
+ Valid commands to rake-server are `start`, `stop`, `run`, and `restart`. Any
28
+ additional arguments name Rake tasks that should be eagerly run when the server
29
+ starts. In the above example, we call the `environment` task, which loads the
30
+ Rails environment for fast invocation of Rails-dependent tasks by the client.
31
+
32
+ === Fork hooks
33
+
34
+ RakeServer forks a separate process each time the client invokes a task. In a
35
+ Rails environment, it's necessary to re-connect to ActiveRecord each time the
36
+ application forks. RakeServer provides pre-fork and post-fork hooks to make this
37
+ easy.
38
+
39
+ First, in your Rakefile:
40
+
41
+ namespace :rake_server
42
+ task :fork_hooks
43
+ RakeServer.before_fork { ActiveRecord::Base.remove_connection }
44
+ RakeServer.after_fork { ActiveRecord::Base.establish_connection }
45
+ end
46
+ end
47
+
48
+ Then, when you start the server, specify your fork hooks setup as an eager task:
49
+
50
+ $ rake-server start environment rake_server:fork_hooks
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.1
1
+ 0.0.2
@@ -24,10 +24,15 @@ module RakeServer
24
24
  end
25
25
 
26
26
  def stop(options = {})
27
- pid_file = File.join(pid_dir(options), "rake-server.pid")
28
- pid = IO.read(pid_file).to_i
29
- Process.kill("TERM", pid)
30
- FileUtils.rm(pid_file)
27
+ if (pid_file = File.join(pid_dir(options), "rake-server.pid"))
28
+ pid = IO.read(pid_file).to_i
29
+ begin
30
+ Process.kill("TERM", pid)
31
+ rescue Errno::ESRCH
32
+ # No worries
33
+ end
34
+ FileUtils.rm(pid_file)
35
+ end
31
36
  end
32
37
 
33
38
  def run(eager_tasks, options = {})
data/pkg/.gitignore ADDED
@@ -0,0 +1 @@
1
+ *
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 0
8
- - 1
9
- version: 0.0.1
8
+ - 2
9
+ version: 0.0.2
10
10
  platform: ruby
11
11
  authors:
12
12
  - Mat Brown
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-04-01 00:00:00 -04:00
18
+ date: 2010-04-07 00:00:00 -04:00
19
19
  default_executable:
20
20
  dependencies: []
21
21
 
@@ -43,6 +43,7 @@ files:
43
43
  - lib/rake_server.rb
44
44
  - lib/rake_server/client.rb
45
45
  - lib/rake_server/server.rb
46
+ - pkg/.gitignore
46
47
  - tasks/gemspec.rake
47
48
  - test/Rakefile
48
49
  - tmp/.gitignore