jaigouk-merb_daemon 0.0.1.5

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/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2009 Jai-Gouk Kim
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.textile ADDED
@@ -0,0 +1,30 @@
1
+ h1. merb_daemon_gen
2
+
3
+ A plugin for creating psuedo-scheduled jobs in merb. This merb plugin is based on dougal / daemon_generator
4
+
5
+ h2. Requirements
6
+
7
+ * merb-core >= 1.0.7.1
8
+ * daemons >= 0.1.10
9
+
10
+ h2. Usage
11
+
12
+ To get yourself rolling:
13
+
14
+ $ sudo gem install daemons
15
+ $ merb-gen daemon <name>
16
+
17
+ Then insert your code in the lib/daemons/<name>.rb stub. All pid's and logs will live in the normal log/ folder. This helps to make things Capistrano friendly.
18
+
19
+ Individual control script:
20
+
21
+ $ ./lib/daemons/<name>_ctl [start|stop|restart]
22
+
23
+ App-wide control script (I add this to my capistrano recipe's after_restart task):
24
+
25
+ $ ./script/daemons [start|stop|restart]
26
+
27
+ h2. Notes
28
+
29
+ * This plugin is not finished yet.
30
+
data/Rakefile ADDED
@@ -0,0 +1,56 @@
1
+ require 'rubygems'
2
+ require 'rake/gempackagetask'
3
+
4
+ require 'merb-core'
5
+ require 'merb-core/tasks/merb'
6
+
7
+ GEM_NAME = "merb_daemon"
8
+ GEM_VERSION = "0.0.1.5"
9
+ AUTHOR = "Jai-Gouk Kim"
10
+ EMAIL = "jaigouk@gmail.com"
11
+ HOMEPAGE = "http://jaigouk.blogspot.com/"
12
+ SUMMARY = "Merb plugin that generates daemons"
13
+
14
+ spec = Gem::Specification.new do |s|
15
+ s.rubyforge_project = 'merb'
16
+ s.name = GEM_NAME
17
+ s.version = GEM_VERSION
18
+ s.platform = Gem::Platform::RUBY
19
+ s.has_rdoc = true
20
+ s.extra_rdoc_files = ["README.textile", "LICENSE", 'TODO']
21
+ s.summary = SUMMARY
22
+ s.description = s.summary
23
+ s.author = AUTHOR
24
+ s.email = EMAIL
25
+ s.homepage = HOMEPAGE
26
+ s.add_dependency('merb', '>= 1.0.7.1')
27
+ s.add_dependency('daemons', '>= 1.0.10')
28
+ s.require_path = 'lib'
29
+ s.files = %w(LICENSE README.textile Rakefile TODO) + Dir.glob("{lib,spec}/**/*")
30
+
31
+ end
32
+
33
+ Rake::GemPackageTask.new(spec) do |pkg|
34
+ pkg.gem_spec = spec
35
+ end
36
+
37
+ desc "install the plugin as a gem"
38
+ task :install do
39
+ Merb::RakeHelper.install(GEM_NAME, :version => GEM_VERSION)
40
+ end
41
+
42
+ desc "Uninstall the gem"
43
+ task :uninstall do
44
+ Merb::RakeHelper.uninstall(GEM_NAME, :version => GEM_VERSION)
45
+ end
46
+
47
+ desc "Create a gemspec file"
48
+ task :gemspec do
49
+ File.open("#{GEM_NAME}.gemspec", "w") do |file|
50
+ file.puts spec.to_ruby
51
+ end
52
+ end
53
+
54
+ require 'spec/rake/spectask'
55
+ require 'merb-core/test/tasks/spectasks'
56
+
data/TODO ADDED
@@ -0,0 +1,7 @@
1
+ TODO:
2
+
3
+
4
+ Add your Merb rake tasks to lib/merb_daemon_gen/merbtasks.rb
5
+
6
+ Switch generator from Rails to Merb
7
+ Figure out how to accept the filename arguments from user.
@@ -0,0 +1,42 @@
1
+ module Merb::Generators
2
+
3
+ class DaemonGenerator < Generator
4
+
5
+ def self.source_root
6
+ File.join(File.dirname(__FILE__), 'daemons', 'templates')
7
+ end
8
+
9
+ desc <<-DESC
10
+ Generates custum daemons
11
+ DESC
12
+
13
+ first_argument :name, :required => true
14
+
15
+ template(:daemon_rb, :after => :chmod) do |t|
16
+ t.source('script.rb')
17
+ t.destination("lib/daemons/#{name}.rb")
18
+ end
19
+
20
+ template(:daemon_ctl, :after => :chmod) do |t|
21
+ t.source('script_ctl')
22
+ t.destination("lib/daemons/#{name}_ctl")
23
+ end
24
+
25
+ template(:daemon, :after => :chmod) do |t|
26
+ t.source('daemons')
27
+ t.destination("lib/daemons")
28
+ end
29
+
30
+ template :daemon_yml do |t|
31
+ t.source(File.dirname(__FILE__) / 'templates' / 'daemons.yml')
32
+ t.destination("config/daemons.yml")
33
+ end
34
+
35
+ def chmod(action)
36
+ File.chmod(0755, action.destination)
37
+ end
38
+
39
+ end
40
+
41
+ add :daemon, DaemonGenerator
42
+ end
@@ -0,0 +1,46 @@
1
+ # links that I referenced to write this plugin
2
+ #http://wiki.merbivore.com/plugindev/generator
3
+ #http://yehudakatz.com/2007/09/19/merb-plugins-oh-yeah-theyre-pretty-frickin-cool-too/
4
+
5
+ module Merb::Generators
6
+
7
+ class DaemonGenerator < NamespacedGenerator
8
+
9
+ def self.source_root
10
+ File.join(File.dirname(__FILE__), 'templates')
11
+ end
12
+
13
+ desc <<-DESC
14
+ Generator that build custum daemon
15
+ DESC
16
+
17
+ first_argument :name, :required => true, :desc => "file name"
18
+
19
+ template :daemon_rb do |t|
20
+ t.source(File.dirname(__FILE__) / 'templates' / '%file_name%.rb')
21
+ t.destination("lib/daemons/#{file_name}.rb")
22
+ end
23
+
24
+ template :daemon_control do |t|
25
+ t.source(File.dirname(__FILE__) / 'templates' / 'script_ctl')
26
+ t.destination("lib/daemons/#{file_name}_ctl")
27
+ end
28
+
29
+ template :daemon do |t|
30
+ t.source(File.dirname(__FILE__) / 'templates' / 'daemons')
31
+ t.destination("lib/daemons")
32
+ end
33
+
34
+ template :daemon_yml do |t|
35
+ t.source(File.dirname(__FILE__) / 'templates' / 'daemons.yml')
36
+ t.destination("config/daemons.yml")
37
+ end
38
+
39
+ def chmod(action)
40
+ File.chmod(0755, action.destination)
41
+ end
42
+
43
+ end
44
+
45
+ add :daemon, DaemonGenerator
46
+ end
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env ruby
2
+ Dir[File.dirname(__FILE__) + "/../lib/daemons/*_ctl"].each {|f| `#{f} #{ARGV.first}`}
@@ -0,0 +1,5 @@
1
+ dir_mode: script
2
+ dir: ../../log
3
+ multiple: false
4
+ backtrace: true
5
+ monitor: true
@@ -0,0 +1,18 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # You might want to change this
4
+ ENV["MERB_ENV"] ||= "production"
5
+
6
+ require File.dirname(__FILE__) + "/../../config/environments"
7
+
8
+ $running = true
9
+ Signal.trap("TERM") do
10
+ $running = false
11
+ end
12
+
13
+ while($running) do
14
+
15
+ # Replace this with your code
16
+ Merb.logger.info("This daemon is still running at #{Time.now}.\n")
17
+ sleep 10
18
+ end
@@ -0,0 +1,24 @@
1
+ #!/usr/bin/env ruby
2
+ require 'rubygems'
3
+ require "daemons"
4
+ require 'yaml'
5
+ require 'erb'
6
+
7
+ if(File.exists?(file_name))
8
+ require file_name
9
+ else
10
+
11
+ #merb_version = Merb::VERSION
12
+ #
13
+ #gem 'activesupport',merb_version
14
+ #require 'active_support'
15
+ end
16
+
17
+ options = YAML.load(
18
+ ERB.new(
19
+ IO.read(
20
+ File.dirname(__FILE__) + "/../../config/daemons.yml"
21
+ )).result).with_indifferent_access
22
+ options[:dir_mode] = options[:dir_mode].to_sym
23
+
24
+ Daemons.run File.dirname(__FILE__) + '/<%=file_name%>.rb', options
@@ -0,0 +1,6 @@
1
+ namespace :merb_daemon do
2
+ desc "Do something for merb_daemon_gen"
3
+ task :default do
4
+ puts "merb_daemon_gen doesn't do anything"
5
+ end
6
+ end
@@ -0,0 +1,21 @@
1
+ # make sure we're running inside Merb
2
+ if defined?(Merb::Plugins)
3
+ dependency "daemons"
4
+ # Merb gives you a Merb::Plugins.config hash...feel free to put your stuff in your piece of it
5
+ Merb::Plugins.config[:merb_daemon] = {
6
+ :chickens => false
7
+ }
8
+
9
+ Merb::BootLoader.before_app_loads do
10
+ # require code that must be loaded before the application
11
+
12
+ end
13
+
14
+ Merb::BootLoader.after_app_loads do
15
+ # code that can be required after the application loads
16
+ end
17
+
18
+ Merb::Plugins.add_rakefiles "merb_daemon/merbtasks"
19
+ end
20
+
21
+
@@ -0,0 +1,7 @@
1
+ require File.dirname(__FILE__) + '/spec_helper'
2
+
3
+ describe "merb_daemon" do
4
+ it "should do nothing" do
5
+ true.should == true
6
+ end
7
+ end
@@ -0,0 +1 @@
1
+ $:.push File.join(File.dirname(__FILE__), '..', 'lib')
metadata ADDED
@@ -0,0 +1,89 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: jaigouk-merb_daemon
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1.5
5
+ platform: ruby
6
+ authors:
7
+ - Jai-Gouk Kim
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-01-14 00:00:00 -08:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: merb
17
+ version_requirement:
18
+ version_requirements: !ruby/object:Gem::Requirement
19
+ requirements:
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: 1.0.7.1
23
+ version:
24
+ - !ruby/object:Gem::Dependency
25
+ name: daemons
26
+ version_requirement:
27
+ version_requirements: !ruby/object:Gem::Requirement
28
+ requirements:
29
+ - - ">="
30
+ - !ruby/object:Gem::Version
31
+ version: 1.0.10
32
+ version:
33
+ description: Merb plugin that provides daemons
34
+ email: jaigouk@gmail.com
35
+ executables: []
36
+
37
+ extensions: []
38
+
39
+ extra_rdoc_files:
40
+ - README.textile
41
+ - LICENSE
42
+ - TODO
43
+ files:
44
+ - LICENSE
45
+ - README.textile
46
+ - Rakefile
47
+ - TODO
48
+ - lib/generators
49
+ - lib/generators/daemons
50
+ - lib/generators/daemons/templates
51
+ - lib/generators/daemons/templates/daemons
52
+ - lib/generators/daemons/templates/daemons.yml
53
+ - lib/generators/daemons/templates/script_ctl
54
+ - lib/generators/daemons/templates/script.rb
55
+ - lib/generators/daemons/daemon_generater.rb
56
+ - lib/generators/daemon_generater.rb
57
+ - lib/merb_daemon
58
+ - lib/merb_daemon/merbtasks.rb
59
+ - lib/merb_daemon.rb
60
+ - spec/spec_helper.rb
61
+ - spec/merb_daemon_spec.rb
62
+ has_rdoc: true
63
+ homepage: http://jaigouk.blogspot.com/
64
+ post_install_message:
65
+ rdoc_options: []
66
+
67
+ require_paths:
68
+ - lib
69
+ required_ruby_version: !ruby/object:Gem::Requirement
70
+ requirements:
71
+ - - ">="
72
+ - !ruby/object:Gem::Version
73
+ version: "0"
74
+ version:
75
+ required_rubygems_version: !ruby/object:Gem::Requirement
76
+ requirements:
77
+ - - ">="
78
+ - !ruby/object:Gem::Version
79
+ version: "0"
80
+ version:
81
+ requirements: []
82
+
83
+ rubyforge_project: merb
84
+ rubygems_version: 1.2.0
85
+ signing_key:
86
+ specification_version: 2
87
+ summary: Merb plugin that provides daemons
88
+ test_files: []
89
+