trinidad_init_services 1.1.5 → 1.1.6

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt CHANGED
@@ -1,3 +1,8 @@
1
+ == 1.1.6 (2012-05-18)
2
+
3
+ * Fix windows option formatting with prunsrv's arguments
4
+ * Detect prunsrv.exe on windows PATH
5
+
1
6
  == 1.1.5 (2012-03-06)
2
7
 
3
8
  * Not working arch detection on Windows + missing 32-bit prunsrv.exe
data/Rakefile CHANGED
@@ -75,8 +75,7 @@ task :release => :build do
75
75
  end
76
76
  sh "git commit --allow-empty -a -m 'Release #{version}'"
77
77
  sh "git tag v#{version}"
78
- sh "git push origin master"
79
- sh "git push --tags"
78
+ sh "git push origin master --tags"
80
79
  sh "gem push pkg/#{gem_file}"
81
80
  end
82
81
 
@@ -1,8 +1,9 @@
1
1
  require 'erb'
2
2
  require 'java'
3
3
  require 'jruby'
4
- require 'rbconfig'
5
4
  require 'fileutils'
5
+ require 'rbconfig'
6
+ require 'shellwords'
6
7
 
7
8
  module Trinidad
8
9
  module InitServices
@@ -39,6 +40,7 @@ module Trinidad
39
40
  collect_windows_opts(options_ask, defaults) if windows?
40
41
 
41
42
  @trinidad_options << (defaults["trinidad_options"] || ask(options_ask, options_default))
43
+ @trinidad_options.map! { |opt| Shellwords.shellsplit(opt) }.flatten!
42
44
  @jruby_home = defaults["jruby_home"] || ask_path('JRuby home?', default_jruby_home)
43
45
  @ruby_compat_version = defaults["ruby_compat_version"] || ask('Ruby 1.8.x or 1.9.x compatibility?', default_ruby_compat_version)
44
46
  @jruby_opts = configure_jruby_opts
@@ -93,29 +95,29 @@ module Trinidad
93
95
  end
94
96
 
95
97
  def configure_windows_service
96
- srv_path = bundled_prunsrv_path
98
+ srv_path = detect_prunsrv_path
97
99
  trinidad_service_id = @trinidad_name.gsub(/\W/, '')
98
100
 
99
101
  command = %Q{//IS//#{trinidad_service_id} --DisplayName="#{@trinidad_name}" \
100
102
  --Install=#{srv_path} --Jvm=auto --StartMode=jvm --StopMode=jvm \
101
103
  --StartClass=com.msp.procrun.JRubyService --StartMethod=start \
102
- --StartParams="#{escape(@trinidad_daemon_path)};#{format_path(@trinidad_options)}" \
103
- --StopClass=com.msp.procrun.JRubyService --StopMethod=stop --Classpath="#{format_path(@classpath)}" \
104
+ --StartParams="#{escape_path(@trinidad_daemon_path)};#{format_options(@trinidad_options)}" \
105
+ --StopClass=com.msp.procrun.JRubyService --StopMethod=stop --Classpath="#{format_options(@classpath)}" \
104
106
  --StdOutput=auto --StdError=auto \
105
107
  --LogPrefix="#{trinidad_service_id.downcase}" \
106
- ++JvmOptions="#{format_path(@jruby_opts)}"
108
+ ++JvmOptions="#{format_options(@jruby_opts)}"
107
109
  }
108
110
  system "#{srv_path} #{command}"
109
111
  end
110
112
 
111
113
  private
112
114
 
113
- def escape(path)
115
+ def escape_path(path)
114
116
  path.gsub(%r{/}, '\\')
115
117
  end
116
-
117
- def format_path(option)
118
- option.map {|o| escape(o)}.join(';')
118
+
119
+ def format_options(options)
120
+ options.map { |opt| escape_path(opt) }.join(';')
119
121
  end
120
122
 
121
123
  def default_jruby_home
@@ -206,6 +208,13 @@ module Trinidad
206
208
  nil
207
209
  end
208
210
 
211
+ def detect_prunsrv_path # only called on windows
212
+ prunsrv_path = `for %i in (prunsrv.exe) do @echo.%~$PATH:i` rescue ''
213
+ # a kind of `which prunsrv.exe` (if not found returns "\n")
214
+ prunsrv_path.chomp!
215
+ prunsrv_path.empty? ? bundled_prunsrv_path : prunsrv_path
216
+ end
217
+
209
218
  def bundled_prunsrv_path(arch = java.lang.System.getProperty("os.arch"))
210
219
  # "amd64", "i386", "x86", "x86_64"
211
220
  path = 'windows'
@@ -1,5 +1,5 @@
1
1
  module Trinidad
2
2
  module InitServices
3
- VERSION = '1.1.5'
3
+ VERSION = '1.1.6'
4
4
  end
5
5
  end
@@ -70,7 +70,7 @@ describe Trinidad::InitServices::Configuration do
70
70
  init_file_content.should =~ /RUN_USER="#{username}"/
71
71
  end
72
72
 
73
- unless (`which make` rescue '').empty?
73
+ unless (`which make` rescue '').chomp.empty?
74
74
 
75
75
  before(:all) do
76
76
  FileUtils.rm_r "/tmp/jsvc-unix-src" if File.exist? "/tmp/jsvc-unix-src"
@@ -120,6 +120,37 @@ describe Trinidad::InitServices::Configuration do
120
120
  path.should == File.join(trinidad_libs, 'windows/prunsrv.exe')
121
121
  end
122
122
 
123
+ it "configures windows service" do
124
+ subject = Trinidad::InitServices::Configuration.new
125
+ subject.instance_eval do
126
+ def windows?; true; end
127
+ def macosx?; false; end
128
+ def system(command); @system_command = command; end
129
+ def system_command; @system_command; end
130
+ end
131
+ config_options = {
132
+ 'app_path' => "C:/MyApp",
133
+ 'ruby_compat_version' => "RUBY1_9",
134
+ 'trinidad_name' => "Trinidad",
135
+ 'trinidad_options' => "-e production -p 4242 ",
136
+ 'java_home' => "C:/Program Files (x86)/jdk-1.7.0",
137
+ 'jruby_home' => "C:/Program Files/jruby",
138
+ }
139
+ subject.configure(config_options)
140
+ subject.system_command.should_not be nil
141
+ subject.system_command.should =~ /--DisplayName="Trinidad"/
142
+ subject.system_command.should =~ /--StartParams=".*?\\daemon.rb;-d;C:\\MyApp;-e;production;-p;4242"/
143
+ subject.system_command.should =~ /--Classpath=\".*?\\jruby-jsvc.jar;.*?\\commons-daemon.jar;.*?\\jruby.jar/
144
+ subject.system_command.should =~ %r{
145
+ \+\+JvmOptions="
146
+ -Djruby.home=C:\\Program\ Files\\jruby;
147
+ -Djruby.lib=C:\\Program\ Files\\jruby\\lib;
148
+ -Djruby.script=jruby;
149
+ -Djruby.daemon.module.name=Trinidad;
150
+ -Djruby.compat.version=RUBY1_9
151
+ "
152
+ }x
153
+ end
123
154
 
124
155
  private
125
156
 
metadata CHANGED
@@ -1,146 +1,127 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: trinidad_init_services
3
3
  version: !ruby/object:Gem::Version
4
- hash: 25
5
4
  prerelease:
6
- segments:
7
- - 1
8
- - 1
9
- - 5
10
- version: 1.1.5
5
+ version: 1.1.6
11
6
  platform: ruby
12
7
  authors:
13
- - David Calavera
8
+ - David Calavera
14
9
  autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
12
 
18
- date: 2012-03-06 00:00:00 Z
13
+ date: 2012-05-18 00:00:00 Z
19
14
  dependencies:
20
- - !ruby/object:Gem::Dependency
21
- name: trinidad
22
- prerelease: false
23
- requirement: &id001 !ruby/object:Gem::Requirement
24
- none: false
25
- requirements:
26
- - - ">="
27
- - !ruby/object:Gem::Version
28
- hash: 31
29
- segments:
30
- - 1
31
- - 3
32
- - 2
33
- version: 1.3.2
34
- type: :runtime
35
- version_requirements: *id001
36
- - !ruby/object:Gem::Dependency
37
- name: rspec
38
- prerelease: false
39
- requirement: &id002 !ruby/object:Gem::Requirement
40
- none: false
41
- requirements:
42
- - - ">="
43
- - !ruby/object:Gem::Version
44
- hash: 17
45
- segments:
46
- - 2
47
- - 7
48
- - 1
49
- version: 2.7.1
50
- type: :development
51
- version_requirements: *id002
52
- - !ruby/object:Gem::Dependency
53
- name: mocha
54
- prerelease: false
55
- requirement: &id003 !ruby/object:Gem::Requirement
56
- none: false
57
- requirements:
58
- - - ">="
59
- - !ruby/object:Gem::Version
60
- hash: 31
61
- segments:
62
- - 0
63
- - 10
64
- version: "0.10"
65
- type: :development
66
- version_requirements: *id003
15
+ - !ruby/object:Gem::Dependency
16
+ name: trinidad
17
+ prerelease: false
18
+ requirement: &id001 !ruby/object:Gem::Requirement
19
+ none: false
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: 1.3.2
24
+ type: :runtime
25
+ version_requirements: *id001
26
+ - !ruby/object:Gem::Dependency
27
+ name: rspec
28
+ prerelease: false
29
+ requirement: &id002 !ruby/object:Gem::Requirement
30
+ none: false
31
+ requirements:
32
+ - - ">="
33
+ - !ruby/object:Gem::Version
34
+ version: 2.7.1
35
+ type: :development
36
+ version_requirements: *id002
37
+ - !ruby/object:Gem::Dependency
38
+ name: mocha
39
+ prerelease: false
40
+ requirement: &id003 !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ">="
44
+ - !ruby/object:Gem::Version
45
+ version: "0.10"
46
+ type: :development
47
+ version_requirements: *id003
67
48
  description: Trinidad init service scripts on Apache Commons Daemon and JRuby-Jsvc, compatible with Unix and Windows services
68
49
  email: calavera@apache.org
69
50
  executables:
70
- - trinidad_init_service
51
+ - trinidad_init_service
71
52
  extensions: []
72
53
 
73
54
  extra_rdoc_files:
74
- - README.md
75
- - LICENSE
55
+ - README.md
56
+ - LICENSE
76
57
  files:
77
- - .gitignore
78
- - Gemfile
79
- - History.txt
80
- - LICENSE
81
- - README.md
82
- - Rakefile
83
- - bin/trinidad_init_service
84
- - init.d/trinidad.erb
85
- - jsvc-unix-src/CHANGES.txt
86
- - jsvc-unix-src/INSTALL.txt
87
- - jsvc-unix-src/Makedefs.in
88
- - jsvc-unix-src/Makefile.in
89
- - jsvc-unix-src/configure
90
- - jsvc-unix-src/configure.in
91
- - jsvc-unix-src/man/README
92
- - jsvc-unix-src/man/fetch.sh
93
- - jsvc-unix-src/man/jsvc.1.xml
94
- - jsvc-unix-src/native/.indent.pro
95
- - jsvc-unix-src/native/Makefile.in
96
- - jsvc-unix-src/native/arguments.c
97
- - jsvc-unix-src/native/arguments.h
98
- - jsvc-unix-src/native/debug.c
99
- - jsvc-unix-src/native/debug.h
100
- - jsvc-unix-src/native/dso-dlfcn.c
101
- - jsvc-unix-src/native/dso-dyld.c
102
- - jsvc-unix-src/native/dso.h
103
- - jsvc-unix-src/native/help.c
104
- - jsvc-unix-src/native/help.h
105
- - jsvc-unix-src/native/home.c
106
- - jsvc-unix-src/native/home.h
107
- - jsvc-unix-src/native/java.c
108
- - jsvc-unix-src/native/java.h
109
- - jsvc-unix-src/native/jsvc-unix.c
110
- - jsvc-unix-src/native/jsvc.h
111
- - jsvc-unix-src/native/location.c
112
- - jsvc-unix-src/native/location.h
113
- - jsvc-unix-src/native/locks.c
114
- - jsvc-unix-src/native/locks.h
115
- - jsvc-unix-src/native/replace.c
116
- - jsvc-unix-src/native/replace.h
117
- - jsvc-unix-src/native/signals.c
118
- - jsvc-unix-src/native/signals.h
119
- - jsvc-unix-src/native/version.h
120
- - jsvc-unix-src/support/apfunctions.m4
121
- - jsvc-unix-src/support/apjava.m4
122
- - jsvc-unix-src/support/apsupport.m4
123
- - jsvc-unix-src/support/buildconf.sh
124
- - jsvc-unix-src/support/config.guess
125
- - jsvc-unix-src/support/config.sub
126
- - jsvc-unix-src/support/install.sh
127
- - jsvc-unix-src/support/mkdist.sh
128
- - lib/trinidad/daemon.rb
129
- - lib/trinidad_init_services.rb
130
- - lib/trinidad_init_services/configuration.rb
131
- - lib/trinidad_init_services/version.rb
132
- - spec/spec_helper.rb
133
- - spec/stubs/trinidad.rb
134
- - spec/stubs/trinidad.yml
135
- - spec/trinidad_daemon_spec.rb
136
- - spec/trinidad_init_services/configuration_spec.rb
137
- - trinidad-libs/commons-daemon.jar
138
- - trinidad-libs/jruby-jsvc.jar
139
- - trinidad-libs/jsvc_darwin
140
- - trinidad-libs/windows/amd64/prunsrv.exe
141
- - trinidad-libs/windows/ia64/prunsrv.exe
142
- - trinidad-libs/windows/prunsrv.exe
143
- - trinidad_init_services.gemspec
58
+ - .gitignore
59
+ - Gemfile
60
+ - History.txt
61
+ - LICENSE
62
+ - README.md
63
+ - Rakefile
64
+ - bin/trinidad_init_service
65
+ - init.d/trinidad.erb
66
+ - jsvc-unix-src/CHANGES.txt
67
+ - jsvc-unix-src/INSTALL.txt
68
+ - jsvc-unix-src/Makedefs.in
69
+ - jsvc-unix-src/Makefile.in
70
+ - jsvc-unix-src/configure
71
+ - jsvc-unix-src/configure.in
72
+ - jsvc-unix-src/man/README
73
+ - jsvc-unix-src/man/fetch.sh
74
+ - jsvc-unix-src/man/jsvc.1.xml
75
+ - jsvc-unix-src/native/.indent.pro
76
+ - jsvc-unix-src/native/Makefile.in
77
+ - jsvc-unix-src/native/arguments.c
78
+ - jsvc-unix-src/native/arguments.h
79
+ - jsvc-unix-src/native/debug.c
80
+ - jsvc-unix-src/native/debug.h
81
+ - jsvc-unix-src/native/dso-dlfcn.c
82
+ - jsvc-unix-src/native/dso-dyld.c
83
+ - jsvc-unix-src/native/dso.h
84
+ - jsvc-unix-src/native/help.c
85
+ - jsvc-unix-src/native/help.h
86
+ - jsvc-unix-src/native/home.c
87
+ - jsvc-unix-src/native/home.h
88
+ - jsvc-unix-src/native/java.c
89
+ - jsvc-unix-src/native/java.h
90
+ - jsvc-unix-src/native/jsvc-unix.c
91
+ - jsvc-unix-src/native/jsvc.h
92
+ - jsvc-unix-src/native/location.c
93
+ - jsvc-unix-src/native/location.h
94
+ - jsvc-unix-src/native/locks.c
95
+ - jsvc-unix-src/native/locks.h
96
+ - jsvc-unix-src/native/replace.c
97
+ - jsvc-unix-src/native/replace.h
98
+ - jsvc-unix-src/native/signals.c
99
+ - jsvc-unix-src/native/signals.h
100
+ - jsvc-unix-src/native/version.h
101
+ - jsvc-unix-src/support/apfunctions.m4
102
+ - jsvc-unix-src/support/apjava.m4
103
+ - jsvc-unix-src/support/apsupport.m4
104
+ - jsvc-unix-src/support/buildconf.sh
105
+ - jsvc-unix-src/support/config.guess
106
+ - jsvc-unix-src/support/config.sub
107
+ - jsvc-unix-src/support/install.sh
108
+ - jsvc-unix-src/support/mkdist.sh
109
+ - lib/trinidad/daemon.rb
110
+ - lib/trinidad_init_services.rb
111
+ - lib/trinidad_init_services/configuration.rb
112
+ - lib/trinidad_init_services/version.rb
113
+ - spec/spec_helper.rb
114
+ - spec/stubs/trinidad.rb
115
+ - spec/stubs/trinidad.yml
116
+ - spec/trinidad_daemon_spec.rb
117
+ - spec/trinidad_init_services/configuration_spec.rb
118
+ - trinidad-libs/commons-daemon.jar
119
+ - trinidad-libs/jruby-jsvc.jar
120
+ - trinidad-libs/jsvc_darwin
121
+ - trinidad-libs/windows/amd64/prunsrv.exe
122
+ - trinidad-libs/windows/ia64/prunsrv.exe
123
+ - trinidad-libs/windows/prunsrv.exe
124
+ - trinidad_init_services.gemspec
144
125
  homepage: http://github.com/trinidad/trinidad_init_services
145
126
  licenses: []
146
127
 
@@ -157,27 +138,21 @@ post_install_message: |+
157
138
  --------------------------------------------------------------------------------
158
139
 
159
140
  rdoc_options:
160
- - --charset=UTF-8
141
+ - --charset=UTF-8
161
142
  require_paths:
162
- - lib
143
+ - lib
163
144
  required_ruby_version: !ruby/object:Gem::Requirement
164
145
  none: false
165
146
  requirements:
166
- - - ">="
167
- - !ruby/object:Gem::Version
168
- hash: 3
169
- segments:
170
- - 0
171
- version: "0"
147
+ - - ">="
148
+ - !ruby/object:Gem::Version
149
+ version: "0"
172
150
  required_rubygems_version: !ruby/object:Gem::Requirement
173
151
  none: false
174
152
  requirements:
175
- - - ">="
176
- - !ruby/object:Gem::Version
177
- hash: 3
178
- segments:
179
- - 0
180
- version: "0"
153
+ - - ">="
154
+ - !ruby/object:Gem::Version
155
+ version: "0"
181
156
  requirements: []
182
157
 
183
158
  rubyforge_project: trinidad_init_services