djinn 0.0.2 → 0.0.3

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.
Files changed (71) hide show
  1. data/.gitignore +3 -1
  2. data/VERSION +1 -1
  3. data/djinn.gemspec +63 -5
  4. data/example/basic.rb +7 -8
  5. data/example/em.rb +1 -1
  6. data/example/event_machine_djinn.pid +1 -0
  7. data/example/rails/demo/Rakefile +10 -0
  8. data/example/rails/demo/app/controllers/application_controller.rb +10 -0
  9. data/example/rails/demo/app/controllers/books_controller.rb +2 -0
  10. data/example/rails/demo/app/helpers/application_helper.rb +3 -0
  11. data/example/rails/demo/app/helpers/books_helper.rb +2 -0
  12. data/example/rails/demo/app/models/book.rb +7 -0
  13. data/example/rails/demo/app/views/books/_book.html.erb +3 -0
  14. data/example/rails/demo/app/views/books/index.html.erb +13 -0
  15. data/example/rails/demo/app/views/layouts/application.html.erb +5 -0
  16. data/example/rails/demo/config/boot.rb +110 -0
  17. data/example/rails/demo/config/database.yml +22 -0
  18. data/example/rails/demo/config/environment.rb +38 -0
  19. data/example/rails/demo/config/environments/development.rb +17 -0
  20. data/example/rails/demo/config/environments/production.rb +28 -0
  21. data/example/rails/demo/config/environments/test.rb +28 -0
  22. data/example/rails/demo/config/initializers/backtrace_silencers.rb +7 -0
  23. data/example/rails/demo/config/initializers/cookie_verification_secret.rb +7 -0
  24. data/example/rails/demo/config/initializers/inflections.rb +10 -0
  25. data/example/rails/demo/config/initializers/mime_types.rb +5 -0
  26. data/example/rails/demo/config/initializers/new_rails_defaults.rb +21 -0
  27. data/example/rails/demo/config/initializers/session_store.rb +15 -0
  28. data/example/rails/demo/config/locales/en.yml +5 -0
  29. data/example/rails/demo/config/routes.rb +6 -0
  30. data/example/rails/demo/db/migrate/20100726151602_create_books.rb +15 -0
  31. data/example/rails/demo/db/schema.rb +23 -0
  32. data/example/rails/demo/db/seeds.rb +15 -0
  33. data/example/rails/demo/doc/README_FOR_APP +2 -0
  34. data/example/rails/demo/lib/book_djinn.rb +25 -0
  35. data/example/rails/demo/public/404.html +30 -0
  36. data/example/rails/demo/public/422.html +30 -0
  37. data/example/rails/demo/public/500.html +30 -0
  38. data/example/rails/demo/public/favicon.ico +0 -0
  39. data/example/rails/demo/public/images/rails.png +0 -0
  40. data/example/rails/demo/public/javascripts/application.js +2 -0
  41. data/example/rails/demo/public/javascripts/controls.js +963 -0
  42. data/example/rails/demo/public/javascripts/dragdrop.js +973 -0
  43. data/example/rails/demo/public/javascripts/effects.js +1128 -0
  44. data/example/rails/demo/public/javascripts/prototype.js +4320 -0
  45. data/example/rails/demo/public/robots.txt +5 -0
  46. data/example/rails/demo/script/about +4 -0
  47. data/example/rails/demo/script/book_djinn +7 -0
  48. data/example/rails/demo/script/console +3 -0
  49. data/example/rails/demo/script/dbconsole +3 -0
  50. data/example/rails/demo/script/destroy +3 -0
  51. data/example/rails/demo/script/generate +3 -0
  52. data/example/rails/demo/script/performance/benchmarker +3 -0
  53. data/example/rails/demo/script/performance/profiler +3 -0
  54. data/example/rails/demo/script/plugin +3 -0
  55. data/example/rails/demo/script/runner +3 -0
  56. data/example/rails/demo/script/server +3 -0
  57. data/example/rails/demo/test/fixtures/books.yml +11 -0
  58. data/example/rails/demo/test/functional/books_controller_test.rb +8 -0
  59. data/example/rails/demo/test/performance/browsing_test.rb +9 -0
  60. data/example/rails/demo/test/test_helper.rb +38 -0
  61. data/example/rails/demo/test/unit/book_test.rb +8 -0
  62. data/example/rails/demo/test/unit/helpers/books_helper_test.rb +4 -0
  63. data/lib/djinn.rb +8 -82
  64. data/lib/djinn/base.rb +82 -0
  65. data/lib/djinn/{logging_helpers.rb → logging.rb} +6 -1
  66. data/lib/djinn/rails.rb +48 -0
  67. data/lib/djinn/rails/handlers.rb +43 -0
  68. data/lib/djinn/tonic.rb +1 -1
  69. metadata +65 -7
  70. data/lib/djinn/rails/boot_daemon.rb +0 -29
  71. data/lib/djinn/rails/daemon_base.rb +0 -99
data/lib/djinn/tonic.rb CHANGED
@@ -12,7 +12,7 @@ module Djinn
12
12
  fork do
13
13
 
14
14
  puts "Daemonizing on process #{$$}"
15
- puts system("ps aux | grep #{$$}")
15
+ # puts system("ps aux | grep #{$$}")
16
16
 
17
17
  # trap('TERM') { do_exit }
18
18
  # trap('INT') { do_exit }
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: 27
4
+ hash: 25
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 2
10
- version: 0.0.2
9
+ - 3
10
+ version: 0.0.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - Craig Paterson
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-07-26 00:00:00 +02:00
18
+ date: 2010-07-27 00:00:00 +02:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -53,11 +53,69 @@ files:
53
53
  - djinn.gemspec
54
54
  - example/basic.rb
55
55
  - example/em.rb
56
+ - example/event_machine_djinn.pid
57
+ - example/rails/demo/Rakefile
58
+ - example/rails/demo/app/controllers/application_controller.rb
59
+ - example/rails/demo/app/controllers/books_controller.rb
60
+ - example/rails/demo/app/helpers/application_helper.rb
61
+ - example/rails/demo/app/helpers/books_helper.rb
62
+ - example/rails/demo/app/models/book.rb
63
+ - example/rails/demo/app/views/books/_book.html.erb
64
+ - example/rails/demo/app/views/books/index.html.erb
65
+ - example/rails/demo/app/views/layouts/application.html.erb
66
+ - example/rails/demo/config/boot.rb
67
+ - example/rails/demo/config/database.yml
68
+ - example/rails/demo/config/environment.rb
69
+ - example/rails/demo/config/environments/development.rb
70
+ - example/rails/demo/config/environments/production.rb
71
+ - example/rails/demo/config/environments/test.rb
72
+ - example/rails/demo/config/initializers/backtrace_silencers.rb
73
+ - example/rails/demo/config/initializers/cookie_verification_secret.rb
74
+ - example/rails/demo/config/initializers/inflections.rb
75
+ - example/rails/demo/config/initializers/mime_types.rb
76
+ - example/rails/demo/config/initializers/new_rails_defaults.rb
77
+ - example/rails/demo/config/initializers/session_store.rb
78
+ - example/rails/demo/config/locales/en.yml
79
+ - example/rails/demo/config/routes.rb
80
+ - example/rails/demo/db/migrate/20100726151602_create_books.rb
81
+ - example/rails/demo/db/schema.rb
82
+ - example/rails/demo/db/seeds.rb
83
+ - example/rails/demo/doc/README_FOR_APP
84
+ - example/rails/demo/lib/book_djinn.rb
85
+ - example/rails/demo/public/404.html
86
+ - example/rails/demo/public/422.html
87
+ - example/rails/demo/public/500.html
88
+ - example/rails/demo/public/favicon.ico
89
+ - example/rails/demo/public/images/rails.png
90
+ - example/rails/demo/public/javascripts/application.js
91
+ - example/rails/demo/public/javascripts/controls.js
92
+ - example/rails/demo/public/javascripts/dragdrop.js
93
+ - example/rails/demo/public/javascripts/effects.js
94
+ - example/rails/demo/public/javascripts/prototype.js
95
+ - example/rails/demo/public/robots.txt
96
+ - example/rails/demo/script/about
97
+ - example/rails/demo/script/book_djinn
98
+ - example/rails/demo/script/console
99
+ - example/rails/demo/script/dbconsole
100
+ - example/rails/demo/script/destroy
101
+ - example/rails/demo/script/generate
102
+ - example/rails/demo/script/performance/benchmarker
103
+ - example/rails/demo/script/performance/profiler
104
+ - example/rails/demo/script/plugin
105
+ - example/rails/demo/script/runner
106
+ - example/rails/demo/script/server
107
+ - example/rails/demo/test/fixtures/books.yml
108
+ - example/rails/demo/test/functional/books_controller_test.rb
109
+ - example/rails/demo/test/performance/browsing_test.rb
110
+ - example/rails/demo/test/test_helper.rb
111
+ - example/rails/demo/test/unit/book_test.rb
112
+ - example/rails/demo/test/unit/helpers/books_helper_test.rb
56
113
  - lib/djinn.rb
57
- - lib/djinn/logging_helpers.rb
114
+ - lib/djinn/base.rb
115
+ - lib/djinn/logging.rb
58
116
  - lib/djinn/pid_file.rb
59
- - lib/djinn/rails/boot_daemon.rb
60
- - lib/djinn/rails/daemon_base.rb
117
+ - lib/djinn/rails.rb
118
+ - lib/djinn/rails/handlers.rb
61
119
  - lib/djinn/tonic.rb
62
120
  - test/helper.rb
63
121
  - test/test_djinn.rb
@@ -1,29 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- $:.unshift(File.dirname(__FILE__))
4
-
5
- require 'rubygems'
6
- require 'optparse'
7
-
8
- environment = ENV["RAILS_ENV"] || "development"
9
- @action = "run"
10
-
11
- OptionParser.new do |opts|
12
- opts.banner = "Usage: social_daemon [options] {start|stop|restart|run}"
13
-
14
- opts.on("-e", "--environment ENV", "Run in specific Rails environment") do |e|
15
- environment = e
16
- end
17
-
18
- @action = opts.permute!(ARGV)
19
- # (puts opts; exit(1)) unless action.size == 1
20
-
21
- @action = @action.first || "run"
22
- (puts opts; exit(1)) unless %w(start stop restart run).include?(@action)
23
-
24
- end.parse!
25
-
26
- ENV["RAILS_ENV"] = environment
27
-
28
- require 'daemon_base'
29
-
@@ -1,99 +0,0 @@
1
- module Djinn
2
- module Rails
3
- class Base
4
-
5
- require 'yaml'
6
- require 'daemon'
7
- require 'pid_file'
8
- require 'daemon_logging'
9
-
10
- extend Djinn::Daemon
11
- include Djinn::LoggingHelpers
12
-
13
- def log m
14
- DaemonBase.log m
15
- end
16
-
17
- class << self
18
-
19
- def log m
20
- puts "#{Time.now.strftime("%m/%d/%Y %H:%M:%S")}: #{m}"
21
- STDOUT.flush
22
- end
23
-
24
- def perform config
25
- raise "Not implemented"
26
- end
27
-
28
- def start
29
- log "Starting #{underscore(self.name)} in the background.."
30
- config = load_config
31
- logfile = get_logfile(config)
32
- daemonize(config, logfile, get_pidfile(config)) do
33
- load_rails
34
- self.new(config).do_stuff
35
- end
36
- end
37
-
38
- def run
39
- log "Starting #{underscore(self.name)} in the foreground.."
40
- load_rails
41
- self.new(load_config).do_stuff
42
- end
43
-
44
- def restart
45
- stop
46
- start
47
- end
48
-
49
- def stop
50
- pidfile = get_pidfile(load_config)
51
- log 'No such process' and exit unless pidfile.pid
52
- begin
53
- log "Sending TERM signal to process #{pidfile.pid}"
54
- Process.kill("TERM", pidfile.pid)
55
- rescue
56
- log 'Could not find process'
57
- ensure
58
- pidfile.remove
59
- end
60
- end
61
-
62
- private
63
-
64
- def get_pidfile(config)
65
- PidFile.new(File.join(File.dirname(__FILE__), '..', '..', 'log', config['pid_file']))
66
- end
67
-
68
- def get_logfile(config)
69
- File.join(File.dirname(__FILE__), '..', '..', 'log', config['log_file'])
70
- end
71
-
72
- def load_rails
73
- log "Loading Rails in #{ENV['RAILS_ENV']} environment"
74
- require File.join(File.dirname(__FILE__), '..', '..', 'config', 'environment')
75
- end
76
-
77
- def load_config
78
- path = File.join(File.dirname(__FILE__), '..', '..', 'config', "#{underscore(self.name)}.yml")
79
- unless File.exists?(path)
80
- log "No config file for daemon: #{path}"
81
- exit(1)
82
- else
83
- YAML.load_file(path)[ENV['RAILS_ENV']]
84
- end
85
- end
86
-
87
- def underscore(camel_cased_word)
88
- camel_cased_word.to_s.gsub(/::/, '/').
89
- gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').
90
- gsub(/([a-z\d])([A-Z])/,'\1_\2').
91
- tr("-", "_").
92
- downcase
93
- end
94
-
95
- end
96
-
97
- end
98
- end
99
- end