trinidad_daemon 0.3.2 → 0.4.0

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/History.txt CHANGED
@@ -1,3 +1,7 @@
1
+ == 0.4.0 (2011-01-13)
2
+
3
+ * Generate Windows service.
4
+
1
5
  == 0.3.2
2
6
 
3
7
  * Remove profile.jar from init script since it's no more bundled with JRuby distribution.
data/README CHANGED
@@ -6,41 +6,54 @@ Trinidad's daemon library based on Apache Commons Daemon and JRuby-jsvc.
6
6
  It should replace the daemon_extension in a near future due to the problem we
7
7
  are finding with the current forking process.
8
8
 
9
- Dependencies
9
+ Installation
10
10
  ============
11
11
 
12
- The Jsvc native binary file is required, but it's already available for all the
13
- platforms supported as a bundled package, i.e:
12
+ When the gem is installed the user must launch the installation process:
14
13
 
15
- Debian/Ubuntu:
16
- $ sudo apt-get install jsvc
17
- Mac OS X:
18
- $ brew install jsvc
14
+ $ jruby -S trinidad_daemon_install
19
15
 
20
- Those binaries are also available in the Apache distribution directory, if
21
- you install it from this directory you must ensure it's in your path:
16
+ This installer guides you through the configuration process and generates a
17
+ init.d script if you are on a unix system or creates the service if you are
18
+ on a windows box.
22
19
 
23
- http://www.apache.org/dist/commons/daemon/binaries/1.0.3/
20
+ Unix
21
+ ====
24
22
 
25
- Installation
26
- ============
23
+ Dependencies
24
+ ============
27
25
 
28
- When the gem is installed the user must launch the installation process:
26
+ The Jsvc native binary file is required, but it's already available for all the
27
+ platforms supported as a bundled package, i.e:
29
28
 
30
- $ jruby -S trinidad_daemon_install
29
+ Debian/Ubuntu:
30
+ $ sudo apt-get install jsvc
31
+ Mac OS X:
32
+ $ brew install jsvc
31
33
 
32
- This installer guides you through the configuration process and generates a
33
- init.d script for your platform.
34
+ Those binaries are also available in the Apache distribution directory, if
35
+ you install it from this directory you must ensure it's in your path:
36
+
37
+ http://www.apache.org/dist/commons/daemon/binaries/
38
+
39
+ Execution
40
+ =========
41
+
42
+ When the installation process finishes you can use the script trinidad-daemon.sh
43
+ generated to launch the server as a daemon with the options start|stop|restart,
44
+ i.e:
45
+
46
+ $ /etc/init.d/trinidad restart
34
47
 
35
- Execution
36
- =========
48
+ Windows
49
+ =======
37
50
 
38
- When the installation process finishes you can use the script trinidad-daemon.sh
39
- generated to launch the server as a daemon with the options start|stop|restart,
40
- i.e:
51
+ Execution
52
+ =========
41
53
 
42
- $ /etc/init.d/trinidad restart
54
+ Open the `Services` panel under `Administrative Tools` and look for a
55
+ service called `Trinidad`.
43
56
 
44
57
  == Copyright
45
58
 
46
- Copyright (c) 2010 David Calavera<calavera@apache.org>. See LICENSE for details.
59
+ Copyright (c) 2011 David Calavera<calavera@apache.org>. See LICENSE for details.
@@ -1,5 +1,3 @@
1
- #!/usr/bin/env jruby
2
-
3
1
  __LIB_DIR__ = File.expand_path('../lib', File.dirname(__FILE__))
4
2
  $LOAD_PATH.unshift(__LIB_DIR__) unless $LOAD_PATH.include? __LIB_DIR__
5
3
 
data/init.d/trinidad.erb CHANGED
@@ -17,12 +17,10 @@ JAVA_HOME=<%= @java_home %>
17
17
  JRUBY_HOME=<%= @jruby_home %>
18
18
  APP_PATH=<%= @app_path %>
19
19
  RUBY_SCRIPT=<%= @trinidad_daemon_path %>
20
- JRUBY_JSVC_JAR=<%= "#{@jars_path}/jruby-jsvc.jar" %>
21
- DAEMON_JAR=<%= "#{@jars_path}/commons-daemon.jar" %>
22
20
 
23
21
  # Add here the options that Trinidad needs to run your application,
24
22
  # but DO NOT delete the -d option, i.e -e production
25
- TRINIDAD_OPTS="-d $APP_PATH <%= @trinidad_options %>"
23
+ TRINIDAD_OPTS="<%= @trinidad_options.join(" ") %>"
26
24
 
27
25
  PIDFILE=<%= @pid_file %>
28
26
  LOG_FILE=<%= @log_file %>
@@ -30,7 +28,7 @@ LOG_FILE=<%= @log_file %>
30
28
  # Implements the jsvc Daemon interface.
31
29
  MAIN_CLASS=com.msp.jsvc.JRubyDaemon
32
30
 
33
- CLASSPATH=$JRUBY_HOME/lib/jruby.jar:<%= @profiler_classpath %>$DAEMON_JAR:$JRUBY_JSVC_JAR
31
+ CLASSPATH=<%= @classpath.join(":") %>
34
32
 
35
33
  # TODO: Allow configuration or detect from the OS
36
34
  JAVA_NATIVE_PROPS="-Djna.boot.library.path=$JRUBY_HOME/lib/native/linux-i386:$JRUBY_HOME/lib/native/linux-amd64 \
@@ -39,11 +37,8 @@ JAVA_NATIVE_PROPS="-Djna.boot.library.path=$JRUBY_HOME/lib/native/linux-i386:$JR
39
37
  JAVA_PROPS="$JAVA_PROPS -Djruby.memory.max=500m \
40
38
  -Djruby.stack.max=1024k \
41
39
  $JAVA_NATIVE_PROPS \
42
- -Djruby.home=$JRUBY_HOME \
43
- -Djruby.lib=$JRUBY_HOME/lib \
44
- -Djruby.script=jruby \
45
- -Djruby.shell=/bin/sh
46
- -Djruby.daemon.module.name=Trinidad"
40
+ -Djruby.shell=/bin/sh \
41
+ <%= @jruby_opts.join(' ') %>"
47
42
 
48
43
  JAVA_OPTS="-Xmx500m -Xss1024k -Xbootclasspath/a:$JRUBY_HOME/lib/jruby.jar"
49
44
 
@@ -2,6 +2,7 @@ module Trinidad
2
2
  module Daemon
3
3
  require 'erb'
4
4
  require 'java'
5
+ require 'rbconfig'
5
6
 
6
7
  class Configuration
7
8
  def initialize(stdin = STDIN, stdout = STDOUT)
@@ -11,18 +12,40 @@ module Trinidad
11
12
 
12
13
  def configure
13
14
  @app_path = ask_path('Application path?')
14
- @trinidad_options = ask('Trinidad options?', '-e production')
15
- @jsvc = ask_path('Jsvc path?', `which jsvc`.chomp)
16
- @java_home = ask_path('Java home?', default_java_home)
15
+ @trinidad_options = ["-d #{@app_path}"]
16
+ options_ask = 'Trinidad options?'
17
+ options_default = '-e production'
18
+ if windows?
19
+ options_ask << '(separated by `;`)'
20
+ options_default = ''
21
+ end
22
+ @trinidad_options << ask(options_ask, options_default)
23
+
17
24
  @jruby_home = ask_path('JRuby home?', default_jruby_home)
18
- @output_path = ask_path('init.d output path?', '/etc/init.d')
19
- @pid_file = ask_path('pid file?', '/var/run/trinidad/trinidad.pid')
20
- @log_file = ask_path('log file?', '/var/log/trinidad/trinidad.log')
25
+ @jruby_opts = ["-Djruby.home=#{@jruby_home}", "-Djruby.lib=#{File.join(@jruby_home, 'lib')}",
26
+ "-Djruby.script=jruby", "-Djruby.daemon.module.name=Trinidad"]
21
27
 
22
28
  @trinidad_daemon_path = File.expand_path('../../trinidad_daemon.rb', __FILE__)
23
29
  @jars_path = File.expand_path('../../../trinidad-libs', __FILE__)
24
30
 
25
- @profiler_classpath = should_use_profile_jar? ? '$JRUBY_HOME/lib/profile.jar:' : ''
31
+ @classpath = ['jruby-jsvc.jar', 'commons-daemon.jar'].map {|jar| File.join(@jars_path, jar)}
32
+ @classpath << File.join(@jruby_home, 'lib', 'jruby.jar')
33
+
34
+ if windows?
35
+ configure_windows_service
36
+ else
37
+ configure_unix_daemon
38
+ end
39
+
40
+ puts 'Done.'
41
+ end
42
+
43
+ def configure_unix_daemon
44
+ @jsvc = ask_path('Jsvc path?', `which jsvc`.chomp)
45
+ @java_home = ask_path('Java home?', default_java_home)
46
+ @output_path = ask_path('init.d output path?', '/etc/init.d')
47
+ @pid_file = ask_path('pid file?', '/var/run/trinidad/trinidad.pid')
48
+ @log_file = ask_path('log file?', '/var/log/trinidad/trinidad.log')
26
49
 
27
50
  daemon = ERB.new(
28
51
  File.read(
@@ -37,7 +60,20 @@ module Trinidad
37
60
 
38
61
  puts "Moving trinidad to #{@output_path}"
39
62
  `cp #{tmp_file} #{@output_path} && chmod u+x #{@output_path}`
40
- puts 'Done.'
63
+ end
64
+
65
+ def configure_windows_service
66
+ prunsrv = File.join(@jars_path, 'prunsrv.exe')
67
+ command = %Q{//IS//Trinidad --DisplayName="Trinidad" \
68
+ --Install="#{prunsrv}" --Jvm=auto --StartMode=jvm --StopMode=jvm \
69
+ --StartClass=com.msp.procrun.JRubyService --StartMethod=start \
70
+ --StartParams="#{@trinidad_daemon_path};#{@trinidad_options.join(";")}" \
71
+ --StopClass=com.msp.procrun.JRubyService --StopMethod=stop --Classpath="#{@classpath.join(";")}" \
72
+ --StdOutput=auto --StdError=auto \
73
+ --LogPrefix="trinidad" \
74
+ ++JvmOptions="#{@jruby_opts.join(";")}"
75
+ }
76
+ system "#{prunsrv} #{command}"
41
77
  end
42
78
 
43
79
  private
@@ -49,9 +85,8 @@ module Trinidad
49
85
  Java::JavaLang::System.get_property("java.home")
50
86
  end
51
87
 
52
- # JRuby versions prior to v1.5.5 required an external profile.jar
53
- def should_use_profile_jar?
54
- JRUBY_VERSION.gsub(".", '').to_i < 155
88
+ def windows?
89
+ RbConfig::CONFIG['host_os'] =~ /mswin|mingw/
55
90
  end
56
91
 
57
92
  def ask_path(question, default = nil)
@@ -3,7 +3,7 @@ require 'trinidad'
3
3
 
4
4
  module Trinidad
5
5
  module Daemon
6
- VERSION = '0.3.2'
6
+ VERSION = '0.4.0'
7
7
 
8
8
  def init
9
9
  end
Binary file
Binary file
Binary file
@@ -13,8 +13,8 @@ Gem::Specification.new do |s|
13
13
  ## If your rubyforge_project name is different, then edit it and comment out
14
14
  ## the sub! line in the Rakefile
15
15
  s.name = 'trinidad_daemon'
16
- s.version = '0.3.2'
17
- s.date = '2010-12-03'
16
+ s.version = '0.4.0'
17
+ s.date = '2011-01-14'
18
18
  s.rubyforge_project = 'trinidad_daemon'
19
19
 
20
20
  ## Make sure your summary is short. The description may be as long
@@ -44,7 +44,7 @@ Gem::Specification.new do |s|
44
44
 
45
45
  ## List your runtime dependencies here. Runtime dependencies are those
46
46
  ## that are needed for an end user to actually USE your code.
47
- s.add_dependency('trinidad', '>=0.9.6')
47
+ s.add_dependency('trinidad', '>=1.0.5')
48
48
 
49
49
  ## Leave this section as-is. It will be automatically generated from the
50
50
  ## contents of your Git repository via the gemspec task. DO NOT REMOVE
@@ -61,6 +61,7 @@ Gem::Specification.new do |s|
61
61
  lib/trinidad_daemon/configuration.rb
62
62
  trinidad-libs/commons-daemon.jar
63
63
  trinidad-libs/jruby-jsvc.jar
64
+ trinidad-libs/prunsrv.exe
64
65
  trinidad_daemon.gemspec
65
66
  ]
66
67
  # = MANIFEST =
metadata CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
6
  - 0
7
- - 3
8
- - 2
9
- version: 0.3.2
7
+ - 4
8
+ - 0
9
+ version: 0.4.0
10
10
  platform: ruby
11
11
  authors:
12
12
  - David Calavera
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-12-03 00:00:00 +01:00
17
+ date: 2011-01-14 00:00:00 +01:00
18
18
  default_executable: trinidad_daemon_install
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -25,10 +25,10 @@ dependencies:
25
25
  - - ">="
26
26
  - !ruby/object:Gem::Version
27
27
  segments:
28
+ - 1
28
29
  - 0
29
- - 9
30
- - 6
31
- version: 0.9.6
30
+ - 5
31
+ version: 1.0.5
32
32
  type: :runtime
33
33
  version_requirements: *id001
34
34
  description: Trinidad daemon based on Apache Commons Daemon and JRuby-jsvc
@@ -51,6 +51,7 @@ files:
51
51
  - lib/trinidad_daemon/configuration.rb
52
52
  - trinidad-libs/commons-daemon.jar
53
53
  - trinidad-libs/jruby-jsvc.jar
54
+ - trinidad-libs/prunsrv.exe
54
55
  - trinidad_daemon.gemspec
55
56
  has_rdoc: true
56
57
  homepage: http://github.com/calavera/trinidad_daemon