djinn 0.0.7 → 0.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.rdoc +1 -1
- data/VERSION +1 -1
- data/djinn.gemspec +1 -1
- data/lib/djinn.rb +1 -0
- data/lib/djinn/base.rb +9 -7
- data/lib/djinn/logging.rb +5 -0
- data/lib/djinn/rails.rb +2 -1
- data/lib/djinn/rails/handlers.rb +3 -2
- metadata +3 -3
data/README.rdoc
CHANGED
@@ -45,7 +45,7 @@ Assuming you didn't sleep there your script would end and the daemon would
|
|
45
45
|
detach and run in the background until it dies or gets killed. You can wrap
|
46
46
|
argument parsing around that if you want, or do it in any other way. By default
|
47
47
|
the daemon will look for a config YAML file in same directory as you executed it
|
48
|
-
from, named the same as the Djinn class, so in this case
|
48
|
+
from, named the same as the Djinn class, so in this case *basic.yml*. It will by
|
49
49
|
default create the pid and log files in the same way. You can change this by
|
50
50
|
putting it in the config file or supplying an options hash:
|
51
51
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.8
|
data/djinn.gemspec
CHANGED
data/lib/djinn.rb
CHANGED
data/lib/djinn/base.rb
CHANGED
@@ -31,25 +31,27 @@ module Djinn
|
|
31
31
|
end
|
32
32
|
|
33
33
|
# Starts the Djinn in the background
|
34
|
-
def start config={}
|
35
|
-
@config = (config.empty?) ? load_config : config
|
34
|
+
def start config={}, &block
|
35
|
+
@config = (config.empty?) ? load_config : config
|
36
36
|
log "Starting #{name} in the background.."
|
37
37
|
logfile = get_logfile(config)
|
38
38
|
daemonize(logfile, get_pidfile(config)) do
|
39
|
+
yield if block_given?
|
39
40
|
trap('TERM') { handle_exit }
|
40
41
|
trap('INT') { handle_exit }
|
41
|
-
perform(config)
|
42
|
+
perform(@config)
|
42
43
|
end
|
43
44
|
end
|
44
45
|
|
45
46
|
# Starts the Djinn in the foreground, which is often useful for
|
46
47
|
# testing or other noble pursuits
|
47
|
-
def run config={}
|
48
|
-
@config = (config.empty?) ? load_config : config
|
48
|
+
def run config={}, &block
|
49
|
+
@config = (config.empty?) ? load_config : config
|
49
50
|
log "Starting #{name} in the foreground.."
|
50
51
|
trap('TERM') { handle_exit }
|
51
52
|
trap('INT') { handle_exit }
|
52
|
-
|
53
|
+
yield if block_given?
|
54
|
+
perform(@config)
|
53
55
|
end
|
54
56
|
|
55
57
|
# Convenience method, really just calls *stop* and then *start* for you :P
|
@@ -61,7 +63,7 @@ module Djinn
|
|
61
63
|
# Stops the Djinn, unless you change the location of the pid file, in
|
62
64
|
# which case its all about you and the *kill* command
|
63
65
|
def stop config={}
|
64
|
-
@config = (config.empty?) ? load_config : config
|
66
|
+
@config = (config.empty?) ? load_config : config
|
65
67
|
pidfile = get_pidfile(@config)
|
66
68
|
log 'No such process' and exit unless pidfile.pid
|
67
69
|
begin
|
data/lib/djinn/logging.rb
CHANGED
data/lib/djinn/rails.rb
CHANGED
data/lib/djinn/rails/handlers.rb
CHANGED
@@ -6,8 +6,9 @@ module Djinn
|
|
6
6
|
|
7
7
|
def go args=[]
|
8
8
|
action = parse_args(args)
|
9
|
-
|
10
|
-
|
9
|
+
self.new.__send__(action.intern) do
|
10
|
+
load_rails unless %w(stop restart).include?(action)
|
11
|
+
end
|
11
12
|
end
|
12
13
|
|
13
14
|
private
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: djinn
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 15
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 8
|
10
|
+
version: 0.0.8
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Craig Paterson
|