mongrel_service 0.4.beta3 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,14 @@
1
+ === 0.4.0 / 2010-11-16
2
+
3
+ * Enhancements:
4
+ * Pass-through arguments during service install. Closes GH-4
5
+ * A bit more verbose messages at install / removal
6
+
7
+ * Bugfixes:
8
+ * Quote service name. Closes GH-3
9
+ * Loose mongrel dependency a little bit for compatibility
10
+ * Service name is mandatory. Closes GH-10
11
+
1
12
  === 0.4.beta3 / 2010-03-07
2
13
 
3
14
  * Bugfixes:
data/README.txt CHANGED
@@ -1,6 +1,6 @@
1
1
  = Mongrel Native Win32 Service Plugin
2
2
 
3
- * http://github.com/fauna/mongrel_service
3
+ * http://github.com/luislavena/mongrel_service
4
4
 
5
5
  == DESCRIPTION
6
6
 
@@ -11,8 +11,8 @@ This replace mongrel_rails_service.
11
11
 
12
12
  Use the following commands to get more help:
13
13
 
14
- service::install --help
15
- service::remove --help
14
+ mongrel_rails service::install --help
15
+ mongrel_rails service::remove --help
16
16
 
17
17
  == AUTHOR
18
18
 
@@ -8,7 +8,7 @@ require 'mongrel_service/service_manager'
8
8
  module Service
9
9
  class Install < GemPlugin::Plugin "/commands"
10
10
  include Mongrel::Command::Base
11
-
11
+
12
12
  def configure
13
13
  options [
14
14
  ['-N', '--name SVC_NAME', "Required name for the service to be registered/installed.", :@svc_name, nil],
@@ -29,17 +29,23 @@ module Service
29
29
  ['', '--prefix PATH', "URL prefix for Rails app", :@prefix, nil]
30
30
  ]
31
31
  end
32
-
32
+
33
33
  # When we validate the options, we need to make sure the --root is actually RAILS_ROOT
34
- # of the rails application we wanted to serve, because later "as service" no error
34
+ # of the rails application we wanted to serve, because later "as service" no error
35
35
  # show to trace this.
36
36
  def validate
37
37
  @cwd = File.expand_path(@cwd)
38
38
  valid_dir? @cwd, "Invalid path to change to: #@cwd"
39
-
39
+
40
40
  # change there to start, then we'll have to come back after daemonize
41
41
  Dir.chdir(@cwd)
42
-
42
+
43
+ valid? @svc_name != nil, "A service name is mandatory."
44
+ valid? !ServiceManager.exist?(@svc_name), "The service already exist, please remove it first."
45
+
46
+ # default service display to service name
47
+ @svc_display = @svc_name if !@svc_display
48
+
43
49
  # start with the premise of app really exist.
44
50
  app_exist = true
45
51
  %w{app config log}.each do |path|
@@ -59,40 +65,29 @@ module Service
59
65
  valid_exists? @mime_map, "MIME mapping file does not exist: #@mime_map" if @mime_map
60
66
  valid_exists? @config_file, "Config file not there: #@config_file" if @config_file
61
67
 
62
- # We should validate service existance here, right Zed?
63
- begin
64
- valid? !ServiceManager.exist?(@svc_name), "The service already exist, please remove it first."
65
- rescue
66
- end
67
-
68
- valid? @svc_name != nil, "A service name is mandatory."
69
-
70
- # default service display to service name
71
- @svc_display = @svc_name if !@svc_display
72
-
73
68
  return @valid
74
69
  end
75
-
70
+
76
71
  def run
77
72
  # check if mongrel_service.exe is in ruby bindir.
78
73
  gem_root = File.join(File.dirname(__FILE__), "..", "..")
79
74
  gem_executable = File.join(gem_root, "resources/mongrel_service.exe")
80
75
  bindir_executable = File.join(Config::CONFIG['bindir'], '/mongrel_service.exe')
81
-
76
+
82
77
  unless File.exist?(bindir_executable)
83
78
  STDERR.puts "** Copying native mongrel_service executable..."
84
79
  FileUtils.cp gem_executable, bindir_executable rescue nil
85
80
  end
86
-
81
+
87
82
  unless FileUtils.compare_file(bindir_executable, gem_executable)
88
83
  STDERR.puts "** Updating native mongrel_service executable..."
89
84
  FileUtils.rm_f bindir_executable rescue nil
90
85
  FileUtils.cp gem_executable, bindir_executable rescue nil
91
86
  end
92
-
87
+
93
88
  # build the command line
94
89
  argv = []
95
-
90
+
96
91
  # start using the native executable
97
92
  argv << '"' + bindir_executable + '"'
98
93
 
@@ -101,7 +96,7 @@ module Service
101
96
 
102
97
  # use the 'single' service for now
103
98
  argv << "single"
104
-
99
+
105
100
  # command line setting override config file settings
106
101
  @options = { :host => @address, :port => @port, :cwd => @cwd,
107
102
  :log_file => @log_file, :pid_file => @pid_file, :environment => @environment,
@@ -109,15 +104,15 @@ module Service
109
104
  :debug => @debug, :includes => ["mongrel"], :config_script => @config_script,
110
105
  :num_procs => @num_procs, :timeout => @timeout, :cpu => @cpu, :prefix => @prefix
111
106
  }
112
-
107
+
113
108
  # if we are using a config file, pass -c and -C to the service instead of each start parameter.
114
109
  if @config_file
115
110
  STDERR.puts "** Using #{@config_file} instead of command line parameters."
116
111
  conf = YAML.load_file(@config_file)
117
-
112
+
118
113
  # add the root folder (-c)
119
114
  argv << "-c \"#{conf[:cwd]}\""
120
-
115
+
121
116
  # use the config file
122
117
  argv << "-C \"#{@config_file}\""
123
118
 
@@ -140,12 +135,16 @@ module Service
140
135
  argv << "--prefix \"#{@options[:prefix]}\"" if @options[:prefix]
141
136
  end
142
137
 
138
+ # concat remaining non-parsed ARGV
139
+ argv.concat(ARGV)
140
+
143
141
  begin
144
142
  ServiceManager.create(
145
143
  @svc_name,
146
144
  @svc_display,
147
145
  argv.join(' ')
148
146
  )
147
+ puts "#{@svc_display} service created."
149
148
  rescue ServiceManager::CreateError => e
150
149
  puts "There was a problem installing the service:"
151
150
  puts e
@@ -159,7 +158,7 @@ module Service
159
158
  ['-N', '--name SVC_NAME', "Required name for the service to be registered/installed.", :@svc_name, nil],
160
159
  ]
161
160
  end
162
-
161
+
163
162
  def validate
164
163
  valid? @svc_name != nil, "A service name is mandatory."
165
164
 
@@ -174,7 +173,7 @@ module Service
174
173
  return @valid
175
174
  end
176
175
  end
177
-
176
+
178
177
  class Remove < GemPlugin::Plugin "/commands"
179
178
  include Mongrel::Command::Base
180
179
  include ServiceValidation
@@ -183,6 +182,7 @@ module Service
183
182
  display_name = ServiceManager.getdisplayname(@svc_name)
184
183
 
185
184
  begin
185
+ puts "Stopping #{display_name} if running..."
186
186
  ServiceManager.stop(@svc_name)
187
187
  rescue ServiceManager::ServiceError => e
188
188
  end
@@ -8,7 +8,7 @@ module ServiceManager
8
8
 
9
9
  def self.create(service_name, display_name, binary_path_name)
10
10
  cmd = ['create']
11
- cmd << service_name
11
+ cmd << quote(service_name)
12
12
  cmd << "DisplayName=" << display_name.inspect
13
13
  cmd << "binPath=" << binary_path_name.inspect
14
14
  status, out = sc(*cmd)
@@ -18,12 +18,12 @@ module ServiceManager
18
18
  end
19
19
 
20
20
  def self.exist?(service_name)
21
- status, out = sc('query', service_name)
21
+ status, out = sc('query', quote(service_name))
22
22
  out =~ /#{service_name}/i
23
23
  end
24
24
 
25
25
  def self.open(service_name)
26
- status, out = sc('qc', service_name, 4096)
26
+ status, out = sc('qc', quote(service_name), 4096)
27
27
  raise ServiceNotFound.new(out) unless status == 0
28
28
 
29
29
  out =~ /BINARY\_PATH\_NAME.*\: (.*)$/
@@ -39,7 +39,7 @@ module ServiceManager
39
39
  end
40
40
 
41
41
  def self.getdisplayname(service_name)
42
- status, out = sc('GetDisplayName', service_name)
42
+ status, out = sc('GetDisplayName', quote(service_name))
43
43
  raise ServiceNotFound.new(out) unless status == 0
44
44
 
45
45
  out =~ /\=(.*)$/
@@ -47,14 +47,14 @@ module ServiceManager
47
47
  end
48
48
 
49
49
  def self.stop(service_name)
50
- status, out = net('stop', service_name)
50
+ status, out = net('stop', quote(service_name))
51
51
  raise ServiceError.new(out) unless status == 0
52
52
 
53
53
  return true
54
54
  end
55
55
 
56
56
  def self.delete(service_name)
57
- status, out = sc('delete', service_name)
57
+ status, out = sc('delete', quote(service_name))
58
58
  raise ServiceError.new(out) unless status == 0
59
59
 
60
60
  return true
@@ -71,4 +71,8 @@ module ServiceManager
71
71
  output = `net #{args.join(' ')} 2>&1`
72
72
  return [$?.exitstatus, output]
73
73
  end
74
+
75
+ def self.quote(text)
76
+ text.inspect
77
+ end
74
78
  end
@@ -6,12 +6,12 @@ task :gem => [:compile]
6
6
 
7
7
  HOE = Hoe.spec 'mongrel_service' do
8
8
  self.rubyforge_name = "mongrel"
9
- self.version = '0.4.beta3'
9
+ self.version = '0.4.0'
10
10
 
11
11
  developer 'Luis Lavena', 'luislavena@gmail.com'
12
12
 
13
13
  extra_deps << ['gem_plugin', '~> 0.2.3']
14
- extra_deps << ['mongrel', '~> 1.1.5']
14
+ extra_deps << ['mongrel', '>= 1.1.5']
15
15
 
16
16
  self.need_tar = false
17
17
  end
metadata CHANGED
@@ -1,7 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mongrel_service
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.beta3
4
+ hash: 15
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 4
9
+ - 0
10
+ version: 0.4.0
5
11
  platform: ruby
6
12
  authors:
7
13
  - Luis Lavena
@@ -9,59 +15,73 @@ autorequire:
9
15
  bindir: bin
10
16
  cert_chain: []
11
17
 
12
- date: 2010-03-07 00:00:00 +01:00
18
+ date: 2010-11-16 00:00:00 -03:00
13
19
  default_executable:
14
20
  dependencies:
15
21
  - !ruby/object:Gem::Dependency
16
22
  name: gem_plugin
17
- type: :runtime
18
- version_requirement:
19
- version_requirements: !ruby/object:Gem::Requirement
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
20
26
  requirements:
21
27
  - - ~>
22
28
  - !ruby/object:Gem::Version
29
+ hash: 17
30
+ segments:
31
+ - 0
32
+ - 2
33
+ - 3
23
34
  version: 0.2.3
24
- version:
35
+ type: :runtime
36
+ version_requirements: *id001
25
37
  - !ruby/object:Gem::Dependency
26
38
  name: mongrel
27
- type: :runtime
28
- version_requirement:
29
- version_requirements: !ruby/object:Gem::Requirement
39
+ prerelease: false
40
+ requirement: &id002 !ruby/object:Gem::Requirement
41
+ none: false
30
42
  requirements:
31
- - - ~>
43
+ - - ">="
32
44
  - !ruby/object:Gem::Version
45
+ hash: 25
46
+ segments:
47
+ - 1
48
+ - 1
49
+ - 5
33
50
  version: 1.1.5
34
- version:
51
+ type: :runtime
52
+ version_requirements: *id002
35
53
  - !ruby/object:Gem::Dependency
36
54
  name: rubyforge
37
- type: :development
38
- version_requirement:
39
- version_requirements: !ruby/object:Gem::Requirement
55
+ prerelease: false
56
+ requirement: &id003 !ruby/object:Gem::Requirement
57
+ none: false
40
58
  requirements:
41
59
  - - ">="
42
60
  - !ruby/object:Gem::Version
61
+ hash: 7
62
+ segments:
63
+ - 2
64
+ - 0
65
+ - 4
43
66
  version: 2.0.4
44
- version:
45
- - !ruby/object:Gem::Dependency
46
- name: gemcutter
47
67
  type: :development
48
- version_requirement:
49
- version_requirements: !ruby/object:Gem::Requirement
50
- requirements:
51
- - - ">="
52
- - !ruby/object:Gem::Version
53
- version: 0.4.1
54
- version:
68
+ version_requirements: *id003
55
69
  - !ruby/object:Gem::Dependency
56
70
  name: hoe
57
- type: :development
58
- version_requirement:
59
- version_requirements: !ruby/object:Gem::Requirement
71
+ prerelease: false
72
+ requirement: &id004 !ruby/object:Gem::Requirement
73
+ none: false
60
74
  requirements:
61
75
  - - ">="
62
76
  - !ruby/object:Gem::Version
63
- version: 2.5.0
64
- version:
77
+ hash: 19
78
+ segments:
79
+ - 2
80
+ - 6
81
+ - 2
82
+ version: 2.6.2
83
+ type: :development
84
+ version_requirements: *id004
65
85
  description: |-
66
86
  This plugin offer native win32 services for rails.
67
87
  This replace mongrel_rails_service.
@@ -111,7 +131,7 @@ files:
111
131
  - TODO.txt
112
132
  - tools/freebasic.rb
113
133
  has_rdoc: true
114
- homepage: http://github.com/fauna/mongrel_service
134
+ homepage: http://github.com/luislavena/mongrel_service
115
135
  licenses: []
116
136
 
117
137
  post_install_message:
@@ -121,21 +141,27 @@ rdoc_options:
121
141
  require_paths:
122
142
  - lib
123
143
  required_ruby_version: !ruby/object:Gem::Requirement
144
+ none: false
124
145
  requirements:
125
146
  - - ">="
126
147
  - !ruby/object:Gem::Version
148
+ hash: 3
149
+ segments:
150
+ - 0
127
151
  version: "0"
128
- version:
129
152
  required_rubygems_version: !ruby/object:Gem::Requirement
153
+ none: false
130
154
  requirements:
131
- - - ">"
155
+ - - ">="
132
156
  - !ruby/object:Gem::Version
133
- version: 1.3.1
134
- version:
157
+ hash: 3
158
+ segments:
159
+ - 0
160
+ version: "0"
135
161
  requirements: []
136
162
 
137
163
  rubyforge_project: mongrel
138
- rubygems_version: 1.3.5
164
+ rubygems_version: 1.3.7
139
165
  signing_key:
140
166
  specification_version: 3
141
167
  summary: This plugin offer native win32 services for rails