Skip to content

Commit

Permalink
fixed some config issues
Browse files Browse the repository at this point in the history
  • Loading branch information
craigp committed Jul 27, 2010
1 parent 0e0f557 commit 94ef58a
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 8 deletions.
2 changes: 1 addition & 1 deletion README.rdoc
Expand Up @@ -45,7 +45,7 @@ Assuming you didn't sleep there your script would end and the daemon would
detach and run in the background until it dies or gets killed. You can wrap
argument parsing around that if you want, or do it in any other way. By default
the daemon will look for a config YAML file in same directory as you executed it
from, named the same as the Djinn class, so in this case _basic.yml_. It will by
from, named the same as the Djinn class, so in this case *basic.yml*. It will by
default create the pid and log files in the same way. You can change this by
putting it in the config file or supplying an options hash:

Expand Down
2 changes: 1 addition & 1 deletion VERSION
@@ -1 +1 @@
0.0.7
0.0.8
2 changes: 1 addition & 1 deletion djinn.gemspec
Expand Up @@ -5,7 +5,7 @@

Gem::Specification.new do |s|
s.name = %q{djinn}
s.version = "0.0.7"
s.version = "0.0.8"

s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
s.authors = ["Craig Paterson"]
Expand Down
1 change: 1 addition & 0 deletions lib/djinn.rb
@@ -1,3 +1,4 @@
require 'yaml'
require 'djinn/base'

# This is a base implementation which handles looking for config
Expand Down
10 changes: 5 additions & 5 deletions lib/djinn/base.rb
Expand Up @@ -32,24 +32,24 @@ def handle_exit

# Starts the Djinn in the background
def start config={}
@config = (config.empty?) ? load_config : config.empty?
@config = (config.empty?) ? load_config : config
log "Starting #{name} in the background.."
logfile = get_logfile(config)
daemonize(logfile, get_pidfile(config)) do
trap('TERM') { handle_exit }
trap('INT') { handle_exit }
perform(config)
perform(@config)
end
end

# Starts the Djinn in the foreground, which is often useful for
# testing or other noble pursuits
def run config={}
@config = (config.empty?) ? load_config : config.empty?
@config = (config.empty?) ? load_config : config
log "Starting #{name} in the foreground.."
trap('TERM') { handle_exit }
trap('INT') { handle_exit }
perform(config)
perform(@config)
end

# Convenience method, really just calls *stop* and then *start* for you :P
Expand All @@ -61,7 +61,7 @@ def restart config={}
# Stops the Djinn, unless you change the location of the pid file, in
# which case its all about you and the *kill* command
def stop config={}
@config = (config.empty?) ? load_config : config.empty?
@config = (config.empty?) ? load_config : config
pidfile = get_pidfile(@config)
log 'No such process' and exit unless pidfile.pid
begin
Expand Down
5 changes: 5 additions & 0 deletions lib/djinn/logging.rb
@@ -1,5 +1,10 @@
module Djinn
module Logging

def djinn_log msg
puts "#{Time.now.strftime("%m/%d/%Y %H:%M:%S")}: #{msg}"
STDOUT.flush
end

def log msg
puts "#{Time.now.strftime("%m/%d/%Y %H:%M:%S")}: #{msg}"
Expand Down
1 change: 1 addition & 0 deletions lib/djinn/rails.rb
@@ -1,5 +1,6 @@
$:.unshift(File.join(File.dirname(__FILE__)))

require 'yaml'
require 'rails/handlers'

module Djinn
Expand Down

0 comments on commit 94ef58a

Please sign in to comment.