daemonic 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 02568ce6526b1a6407039c4abb9b45d005bf5e7f
4
- data.tar.gz: 388216ee58cdbc4b272f15b76df288ebe65d29c0
3
+ metadata.gz: 08967f54a434d3f2a95afdff4d3012de7e4667f3
4
+ data.tar.gz: def0f290d179d0e77d20641773febe003faeefe8
5
5
  SHA512:
6
- metadata.gz: d4d4bd93c7b5f861f7bc1fb575bb613ee9756a5a285f618821ce4b649592cdf3fd83fec2be636213088eeb19944cfde31c0d3dc738b6dd2665bb0a2b37dec110
7
- data.tar.gz: 80879158acec4db8a26fdc654ff8329f410ff92c6b93f0c31a2ed99e09991afdce1ec12d2492c98e8653e915ba2b0a38f955b63bf96f5e716bed449ab641c80d
6
+ metadata.gz: 8207b32bb5fb5775ce32c3e13beca35c959da25fd3c9ffbb212e43e5ab902303c53ff62c126fe5dc3c9a9f2d1bb596fa451710f7e9fd3f7eff2f7c4a34d689bf
7
+ data.tar.gz: ccdc7553329447f58460b573c29e585b044acf334ba79a0df553bd05bd9e908c7cd8d877dd660798fcca15bba6de417ce5d54c9190782f04dea06f9fc35f67bc
data/README.md CHANGED
@@ -47,9 +47,7 @@ class FeedWorker
47
47
 
48
48
  end
49
49
 
50
- feed_worker = FeedWorker.new
51
-
52
- Daemonic.run(feed_worker)
50
+ Daemonic.run { FeedWorker.new }
53
51
  ```
54
52
 
55
53
  Make the file executable:
@@ -101,7 +99,7 @@ multi-threaded daemon:
101
99
  * Create an executable.
102
100
  * Require daemonic.
103
101
  * Require your own worker.
104
- * End the executable with `Daemonic.run(my_worker)`.
102
+ * End the executable with `Daemonic.run { my_worker }`.
105
103
 
106
104
  You can get help, by running the script you created:
107
105
 
File without changes
@@ -22,9 +22,7 @@ Feature: Worker
22
22
 
23
23
  end
24
24
 
25
- worker = MyWorker.new
26
-
27
- Daemonic.run(worker)
25
+ Daemonic.run { MyWorker.new }
28
26
  """
29
27
 
30
28
  When I run `./worker start --daemonize --pid tmp/worker.pid`
@@ -1,3 +1,3 @@
1
1
  module Daemonic
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
data/lib/daemonic.rb CHANGED
@@ -14,19 +14,20 @@ Thread.abort_on_exception = true
14
14
 
15
15
  module Daemonic
16
16
 
17
- def self.run(worker, default_options = {})
17
+ def self.run(default_options = {}, &worker_proc)
18
18
  command, options = CLI.new(ARGV, default_options).run
19
19
  case command
20
- when :start then start(worker, options)
20
+ when :start then start(options, &worker_proc)
21
21
  when :stop then stop(options)
22
22
  when :status then status(options)
23
- when :restart then restart(worker, options)
23
+ when :restart then restart(options, &worker_proc)
24
24
  end
25
25
  end
26
26
 
27
- def self.start(worker, options)
27
+ def self.start(options, &worker_proc)
28
28
  daemon = Daemon.new(options)
29
29
  daemon.start do
30
+ worker = worker_proc.call
30
31
  Producer.new(worker, options).run
31
32
  end
32
33
  end
@@ -39,9 +40,10 @@ module Daemonic
39
40
  Daemon.new(options).status
40
41
  end
41
42
 
42
- def self.restart(worker, options)
43
+ def self.restart(options, &worker_proc)
43
44
  daemon = Daemon.new(options.merge(daemonize: true))
44
45
  daemon.restart do
46
+ worker = worker_proc.call
45
47
  Producer.new(worker, options).run
46
48
  end
47
49
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: daemonic
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - iain
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-07-16 00:00:00.000000000 Z
11
+ date: 2014-07-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -96,7 +96,7 @@ files:
96
96
  - daemonic.gemspec
97
97
  - examples/init-d.sh
98
98
  - examples/rss
99
- - features/support/env.rb
99
+ - features/support/aruba.rb
100
100
  - features/worker.feature
101
101
  - lib/daemonic.rb
102
102
  - lib/daemonic/cli.rb
@@ -129,6 +129,6 @@ signing_key:
129
129
  specification_version: 4
130
130
  summary: Daemonic makes multi-threaded daemons easy.
131
131
  test_files:
132
- - features/support/env.rb
132
+ - features/support/aruba.rb
133
133
  - features/worker.feature
134
134
  has_rdoc: