trinidad_init_services 1.0.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 +37 -0
- data/LICENSE +26 -0
- data/README +42 -0
- data/Rakefile +154 -0
- data/bin/trinidad_init_service +3 -0
- data/init.d/trinidad.erb +125 -0
- data/lib/trinidad_init_services.rb +30 -0
- data/lib/trinidad_init_services/configuration.rb +152 -0
- data/trinidad-libs/commons-daemon.jar +0 -0
- data/trinidad-libs/jruby-jsvc.jar +0 -0
- data/trinidad-libs/jsvc_darwin +0 -0
- data/trinidad-libs/jsvc_linux +0 -0
- data/trinidad-libs/prunsrv.exe +0 -0
- data/trinidad_init_services.gemspec +88 -0
- metadata +91 -0
data/History.txt
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
== 1.0.0 (2011-06-11)
|
2
|
+
|
3
|
+
* Rebranded gem
|
4
|
+
* Fix shutdown compatibility errors with Trinidad 1.2.2 and above
|
5
|
+
|
6
|
+
== 0.4.2 (2011-05-17)
|
7
|
+
|
8
|
+
* fix several minor bugs
|
9
|
+
|
10
|
+
== 0.4.1 (2011-01-18)
|
11
|
+
|
12
|
+
* Ensure the unix script is executable by default.
|
13
|
+
|
14
|
+
== 0.4.0 (2011-01-13)
|
15
|
+
|
16
|
+
* Generate Windows service.
|
17
|
+
|
18
|
+
== 0.3.2
|
19
|
+
|
20
|
+
* Remove profile.jar from init script since it's no more bundled with JRuby distribution.
|
21
|
+
|
22
|
+
== 0.3.1
|
23
|
+
|
24
|
+
* Use absolute path for configuration options
|
25
|
+
* Start Trinidad from the application path
|
26
|
+
|
27
|
+
== 0.3.0
|
28
|
+
|
29
|
+
* Remove init script extension
|
30
|
+
|
31
|
+
== 0.2.0
|
32
|
+
|
33
|
+
* Fix several bugs
|
34
|
+
|
35
|
+
== 0.1.0
|
36
|
+
|
37
|
+
* Initial release
|
data/LICENSE
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
== Trinidad
|
2
|
+
|
3
|
+
Copyright (c) 2009 David Calavera
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
23
|
+
|
24
|
+
== Additional Bundled Software
|
25
|
+
|
26
|
+
Apache Commons Daemon is licensed according to the terms of Apache License, Version 2.0 (current). See http://www.apache.org/licenses/LICENSE-2.0 for details.
|
data/README
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
Trinidad init services
|
2
|
+
===============
|
3
|
+
|
4
|
+
Trinidad's init services library based on Apache Commons Daemon and JRuby-jsvc. Works on Unix and Windows systems.
|
5
|
+
|
6
|
+
Installation
|
7
|
+
============
|
8
|
+
|
9
|
+
$ jruby -S gem install trinidad_init_services
|
10
|
+
|
11
|
+
When the gem is installed the user must launch the installation process:
|
12
|
+
|
13
|
+
$ jruby -S trinidad_init_service
|
14
|
+
|
15
|
+
This installer guides you through the configuration process and generates a
|
16
|
+
init.d script if you are on a unix system or creates the service if you are
|
17
|
+
on a windows box.
|
18
|
+
|
19
|
+
Unix
|
20
|
+
====
|
21
|
+
|
22
|
+
Execution
|
23
|
+
=========
|
24
|
+
|
25
|
+
When the installation process finishes you can use the script trinidad-daemon.sh
|
26
|
+
generated to launch the server as a daemon with the options start|stop|restart,
|
27
|
+
i.e:
|
28
|
+
|
29
|
+
$ /etc/init.d/trinidad restart
|
30
|
+
|
31
|
+
Windows
|
32
|
+
=======
|
33
|
+
|
34
|
+
Execution
|
35
|
+
=========
|
36
|
+
|
37
|
+
Open the `Services` panel under `Administrative Tools` and look for a
|
38
|
+
service called `Trinidad`.
|
39
|
+
|
40
|
+
== Copyright
|
41
|
+
|
42
|
+
Copyright (c) 2011 David Calavera<calavera@apache.org>. See LICENSE for details.
|
data/Rakefile
ADDED
@@ -0,0 +1,154 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
require 'date'
|
4
|
+
|
5
|
+
#############################################################################
|
6
|
+
#
|
7
|
+
# Helper functions
|
8
|
+
#
|
9
|
+
#############################################################################
|
10
|
+
|
11
|
+
def name
|
12
|
+
@name ||= Dir['*.gemspec'].first.split('.').first
|
13
|
+
end
|
14
|
+
|
15
|
+
def version
|
16
|
+
line = File.read("lib/#{name}.rb")[/^\s*VERSION\s*=\s*.*/]
|
17
|
+
line.match(/.*VERSION\s*=\s*['"](.*)['"]/)[1]
|
18
|
+
end
|
19
|
+
|
20
|
+
def date
|
21
|
+
Date.today.to_s
|
22
|
+
end
|
23
|
+
|
24
|
+
def rubyforge_project
|
25
|
+
name
|
26
|
+
end
|
27
|
+
|
28
|
+
def gemspec_file
|
29
|
+
"#{name}.gemspec"
|
30
|
+
end
|
31
|
+
|
32
|
+
def gem_file
|
33
|
+
"#{name}-#{version}.gem"
|
34
|
+
end
|
35
|
+
|
36
|
+
def replace_header(head, header_name)
|
37
|
+
head.sub!(/(\.#{header_name}\s*= ').*'/) { "#{$1}#{send(header_name)}'"}
|
38
|
+
end
|
39
|
+
|
40
|
+
#############################################################################
|
41
|
+
#
|
42
|
+
# Standard tasks
|
43
|
+
#
|
44
|
+
#############################################################################
|
45
|
+
|
46
|
+
task :default => :test
|
47
|
+
|
48
|
+
require 'rake/testtask'
|
49
|
+
Rake::TestTask.new(:test) do |test|
|
50
|
+
test.libs << 'lib' << 'test'
|
51
|
+
test.pattern = 'test/**/test_*.rb'
|
52
|
+
test.verbose = true
|
53
|
+
end
|
54
|
+
|
55
|
+
desc "Generate RCov test coverage and open in your browser"
|
56
|
+
task :coverage do
|
57
|
+
require 'rcov'
|
58
|
+
sh "rm -fr coverage"
|
59
|
+
sh "rcov test/test_*.rb"
|
60
|
+
sh "open coverage/index.html"
|
61
|
+
end
|
62
|
+
|
63
|
+
require 'rake/rdoctask'
|
64
|
+
Rake::RDocTask.new do |rdoc|
|
65
|
+
rdoc.rdoc_dir = 'rdoc'
|
66
|
+
rdoc.title = "#{name} #{version}"
|
67
|
+
rdoc.rdoc_files.include('README*')
|
68
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
69
|
+
end
|
70
|
+
|
71
|
+
desc "Open an irb session preloaded with this library"
|
72
|
+
task :console do
|
73
|
+
sh "irb -rubygems -r ./lib/#{name}.rb"
|
74
|
+
end
|
75
|
+
|
76
|
+
#############################################################################
|
77
|
+
#
|
78
|
+
# Custom tasks (add your own tasks here)
|
79
|
+
#
|
80
|
+
#############################################################################
|
81
|
+
|
82
|
+
|
83
|
+
|
84
|
+
#############################################################################
|
85
|
+
#
|
86
|
+
# Packaging tasks
|
87
|
+
#
|
88
|
+
#############################################################################
|
89
|
+
|
90
|
+
desc 'Release gem'
|
91
|
+
task :release => :build do
|
92
|
+
unless `git branch` =~ /^\* master$/
|
93
|
+
puts "You must be on the master branch to release!"
|
94
|
+
exit!
|
95
|
+
end
|
96
|
+
sh "git commit --allow-empty -a -m 'Release #{version}'"
|
97
|
+
sh "git tag v#{version}"
|
98
|
+
sh "git push origin master"
|
99
|
+
sh "git push --tags"
|
100
|
+
sh "gem push pkg/#{gem_file}"
|
101
|
+
end
|
102
|
+
|
103
|
+
desc 'Build gem'
|
104
|
+
task :build => :gemspec do
|
105
|
+
sh "mkdir -p pkg"
|
106
|
+
sh "gem build #{gemspec_file}"
|
107
|
+
sh "mv #{gem_file} pkg"
|
108
|
+
end
|
109
|
+
|
110
|
+
desc 'Install gem'
|
111
|
+
task :install => :build do
|
112
|
+
sh "gem install pkg/#{gem_file}"
|
113
|
+
end
|
114
|
+
|
115
|
+
desc 'Create gemspec'
|
116
|
+
task :gemspec => :validate do
|
117
|
+
# read spec file and split out manifest section
|
118
|
+
spec = File.read(gemspec_file)
|
119
|
+
head, manifest, tail = spec.split(" # = MANIFEST =\n")
|
120
|
+
|
121
|
+
# replace name version and date
|
122
|
+
replace_header(head, :name)
|
123
|
+
replace_header(head, :version)
|
124
|
+
replace_header(head, :date)
|
125
|
+
#comment this out if your rubyforge_project has a different name
|
126
|
+
replace_header(head, :rubyforge_project)
|
127
|
+
|
128
|
+
# determine file list from git ls-files
|
129
|
+
files = `git ls-files`.
|
130
|
+
split("\n").
|
131
|
+
sort.
|
132
|
+
reject { |file| file =~ /^\./ }.
|
133
|
+
reject { |file| file =~ /^(rdoc|pkg)/ }.
|
134
|
+
map { |file| " #{file}" }.
|
135
|
+
join("\n")
|
136
|
+
|
137
|
+
# piece file back together and write
|
138
|
+
manifest = " s.files = %w[\n#{files}\n ]\n"
|
139
|
+
spec = [head, manifest, tail].join(" # = MANIFEST =\n")
|
140
|
+
File.open(gemspec_file, 'w') { |io| io.write(spec) }
|
141
|
+
puts "Updated #{gemspec_file}"
|
142
|
+
end
|
143
|
+
|
144
|
+
task :validate do
|
145
|
+
libfiles = Dir['lib/*'] - ["lib/#{name}.rb", "lib/#{name}"]
|
146
|
+
unless libfiles.empty?
|
147
|
+
puts "Directory `lib` should only contain a `#{name}.rb` file and `#{name}` dir."
|
148
|
+
exit!
|
149
|
+
end
|
150
|
+
unless Dir['VERSION*'].empty?
|
151
|
+
puts "A `VERSION` file at root level violates Gem best practices."
|
152
|
+
exit!
|
153
|
+
end
|
154
|
+
end
|
data/init.d/trinidad.erb
ADDED
@@ -0,0 +1,125 @@
|
|
1
|
+
#! /bin/sh
|
2
|
+
# Generic script for running ruby scripts as daemons using
|
3
|
+
# jsvc and a java class to control the daemon.
|
4
|
+
#
|
5
|
+
# Contains common parameters and start/stop
|
6
|
+
|
7
|
+
# Things you'll need to set on a per script/daemon basis:
|
8
|
+
# SCRIPT_NAME - Path to the ruby script which creates a Daemon
|
9
|
+
# object for jsvc to control
|
10
|
+
# APP_NAME - Name of your application
|
11
|
+
#
|
12
|
+
# Things you can set:
|
13
|
+
# PROG_OPTS - Arguments to send to the program. A few defaults are appended to this.
|
14
|
+
|
15
|
+
JSVC=<%= @jsvc %>
|
16
|
+
JAVA_HOME=<%= @java_home %>
|
17
|
+
JRUBY_HOME=<%= @jruby_home %>
|
18
|
+
APP_PATH=<%= @app_path %>
|
19
|
+
RUBY_SCRIPT=<%= @trinidad_daemon_path %>
|
20
|
+
|
21
|
+
# Add here the options that Trinidad needs to run your application,
|
22
|
+
# but DO NOT delete the -d option, i.e -e production
|
23
|
+
TRINIDAD_OPTS="<%= @trinidad_options.join(" ") %>"
|
24
|
+
|
25
|
+
PIDFILE=<%= @pid_file %>
|
26
|
+
LOG_FILE=<%= @log_file %>
|
27
|
+
|
28
|
+
# Implements the jsvc Daemon interface.
|
29
|
+
MAIN_CLASS=com.msp.jsvc.JRubyDaemon
|
30
|
+
|
31
|
+
CLASSPATH=<%= @classpath.join(":") %>
|
32
|
+
|
33
|
+
if [ -z "$JRUBY_OPTS" ] ; then
|
34
|
+
JRUBY_OPTS=""
|
35
|
+
fi
|
36
|
+
|
37
|
+
# TODO: Allow configuration or detect from the OS
|
38
|
+
JAVA_NATIVE_PROPS="-Djna.boot.library.path=$JRUBY_HOME/lib/native/linux-i386:$JRUBY_HOME/lib/native/linux-amd64 \
|
39
|
+
-Djffi.boot.library.path=$JRUBY_HOME/lib/native/i386-Linux:$JRUBY_HOME/lib/native/s390x-Linux:$JRUBY_HOME/lib/native/x86_64-Linux"
|
40
|
+
|
41
|
+
JAVA_PROPS="$JAVA_PROPS -Djruby.memory.max=500m \
|
42
|
+
-Djruby.stack.max=1024k \
|
43
|
+
$JAVA_NATIVE_PROPS \
|
44
|
+
-Djruby.shell=/bin/sh \
|
45
|
+
<%= @jruby_opts.join(' ') %> \
|
46
|
+
$JRUBY_OPTS"
|
47
|
+
|
48
|
+
JAVA_OPTS="-Xmx500m -Xss1024k -Xbootclasspath/a:$JRUBY_HOME/lib/jruby.jar"
|
49
|
+
|
50
|
+
JSVC_ARGS="-home $JAVA_HOME \
|
51
|
+
$JSVC_ARGS_EXTRA \
|
52
|
+
-wait 20 \
|
53
|
+
-pidfile $PIDFILE \
|
54
|
+
-user $USER \
|
55
|
+
-procname jsvc-$SCRIPT_NAME \
|
56
|
+
-jvm server
|
57
|
+
-outfile $LOG_FILE \
|
58
|
+
-errfile &1"
|
59
|
+
|
60
|
+
#
|
61
|
+
# Stop/Start
|
62
|
+
#
|
63
|
+
|
64
|
+
STOP_COMMAND="$JSVC $JSVC_ARGS -stop $MAIN_CLASS"
|
65
|
+
START_COMMAND="$JSVC $JSVC_ARGS -cp $CLASSPATH $JAVA_PROPS $JAVA_OPTS $MAIN_CLASS $RUBY_SCRIPT $TRINIDAD_OPTS"
|
66
|
+
|
67
|
+
cd $APP_PATH || exit 1
|
68
|
+
|
69
|
+
case "$1" in
|
70
|
+
start)
|
71
|
+
if [ -e "$PIDFILE" ]; then
|
72
|
+
echo "Pidfile already exists, not starting."
|
73
|
+
exit 1
|
74
|
+
else
|
75
|
+
echo "Starting $SCRIPT_NAME daemon..."
|
76
|
+
$START_COMMAND
|
77
|
+
EXIT_CODE=$?
|
78
|
+
if [ "$EXIT_CODE" != 0 ]; then
|
79
|
+
echo "Daemon exited with status: $EXIT_CODE. Check pidfile and log"
|
80
|
+
fi
|
81
|
+
fi
|
82
|
+
;;
|
83
|
+
stop)
|
84
|
+
if [ -e "$PIDFILE" ]; then
|
85
|
+
echo "Stopping $SCRIPT_NAME daemon..."
|
86
|
+
$STOP_COMMAND
|
87
|
+
else
|
88
|
+
echo "No pid file, not stopping."
|
89
|
+
exit 1
|
90
|
+
fi
|
91
|
+
;;
|
92
|
+
restart)
|
93
|
+
if [ -e "$PIDFILE" ]; then
|
94
|
+
echo "Stopping $SCRIPT_NAME daemon..."
|
95
|
+
$STOP_COMMAND
|
96
|
+
fi
|
97
|
+
if [ -e "$PIDFILE" ]; then
|
98
|
+
echo "Pidfile still present, $SCRIPT_NAME hasn't stopped"
|
99
|
+
exit 1
|
100
|
+
else
|
101
|
+
$START_COMMAND
|
102
|
+
EXIT_CODE=$?
|
103
|
+
if [ "$EXIT_CODE" != 0 ]; then
|
104
|
+
echo "Daemon exited with status: $EXIT_CODE. Check pidfile and log"
|
105
|
+
fi
|
106
|
+
fi
|
107
|
+
;;
|
108
|
+
status)
|
109
|
+
if [ "$PIDFILE" ]; then
|
110
|
+
PID=`cat $PIDFILE`
|
111
|
+
OUTPUT=`ps $PID | egrep "^$PID "`
|
112
|
+
if [ ${#OUTPUT} -gt 0 ]; then
|
113
|
+
echo "Service running with pid: $PID"
|
114
|
+
else
|
115
|
+
echo "Pidfile present, but process not running"
|
116
|
+
fi
|
117
|
+
else
|
118
|
+
echo "No pidfile present"
|
119
|
+
fi
|
120
|
+
;;
|
121
|
+
*)
|
122
|
+
echo "Unrecognised command. Usage trinidad [ start | stop | restart ]"
|
123
|
+
;;
|
124
|
+
esac
|
125
|
+
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'trinidad'
|
3
|
+
|
4
|
+
module Trinidad
|
5
|
+
module Daemon
|
6
|
+
VERSION = '1.0.0'
|
7
|
+
|
8
|
+
def init
|
9
|
+
end
|
10
|
+
|
11
|
+
def setup?
|
12
|
+
true
|
13
|
+
end
|
14
|
+
|
15
|
+
def start
|
16
|
+
opts = Trinidad::CommandLineParser.parse(ARGV)
|
17
|
+
opts[:trap] = false
|
18
|
+
@server = Trinidad::Server.new(opts)
|
19
|
+
@server.start
|
20
|
+
end
|
21
|
+
|
22
|
+
def stop
|
23
|
+
@server.stop
|
24
|
+
end
|
25
|
+
|
26
|
+
extend self
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
Trinidad::Daemon.init
|
@@ -0,0 +1,152 @@
|
|
1
|
+
module Trinidad
|
2
|
+
module InitServices
|
3
|
+
require 'erb'
|
4
|
+
require 'java'
|
5
|
+
require 'rbconfig'
|
6
|
+
require 'fileutils'
|
7
|
+
|
8
|
+
class Configuration
|
9
|
+
def initialize(stdin = STDIN, stdout = STDOUT)
|
10
|
+
@stdin = stdin
|
11
|
+
@stdout = stdout
|
12
|
+
end
|
13
|
+
|
14
|
+
def initialize_paths
|
15
|
+
@trinidad_daemon_path = File.expand_path('../../trinidad_init_services.rb', __FILE__)
|
16
|
+
@jars_path = File.expand_path('../../../trinidad-libs', __FILE__)
|
17
|
+
|
18
|
+
@classpath = ['jruby-jsvc.jar', 'commons-daemon.jar'].map { |jar| File.join(@jars_path, jar) }
|
19
|
+
@classpath << File.join(@jruby_home, 'lib', 'jruby.jar')
|
20
|
+
end
|
21
|
+
|
22
|
+
def collect_windows_opts(options_ask)
|
23
|
+
options_ask << '(separated by `;`)'
|
24
|
+
name_ask = 'Service name? {Alphanumeric and spaces only}'
|
25
|
+
name_default = 'Trinidad'
|
26
|
+
@trinidad_name = ask(name_ask, name_default)
|
27
|
+
end
|
28
|
+
|
29
|
+
def configure_jruby_opts
|
30
|
+
opts = []
|
31
|
+
opts << "-Djruby.home=#{@jruby_home}"
|
32
|
+
opts << "-Djruby.lib=#{File.join(@jruby_home, 'lib')}"
|
33
|
+
opts << "-Djruby.script=jruby"
|
34
|
+
opts << "-Djruby.daemon.module.name=Trinidad"
|
35
|
+
opts << "-Djruby.compat.version=#{@ruby_compat_version}"
|
36
|
+
opts
|
37
|
+
end
|
38
|
+
|
39
|
+
def configure
|
40
|
+
@app_path = ask_path('Application path?')
|
41
|
+
@trinidad_options = ["-d #{@app_path}"]
|
42
|
+
options_ask = 'Trinidad options?'
|
43
|
+
options_default = '-e production'
|
44
|
+
collect_windows_opts(options_ask) if windows?
|
45
|
+
|
46
|
+
@trinidad_options << ask(options_ask, options_default)
|
47
|
+
@jruby_home = ask_path('JRuby home?', default_jruby_home)
|
48
|
+
@ruby_compat_version = ask('Ruby 1.8.x or 1.9.x compatibility?', default_ruby_compat_version)
|
49
|
+
@jruby_opts = configure_jruby_opts
|
50
|
+
initialize_paths
|
51
|
+
|
52
|
+
windows? ? configure_windows_service : configure_unix_daemon
|
53
|
+
puts 'Done.'
|
54
|
+
end
|
55
|
+
|
56
|
+
def configure_unix_daemon
|
57
|
+
@jsvc = jsvc_path
|
58
|
+
@java_home = ask_path('Java home?', default_java_home)
|
59
|
+
@output_path = ask_path('init.d output path?', '/etc/init.d')
|
60
|
+
@pid_file = ask_path('pid file?', '/var/run/trinidad/trinidad.pid')
|
61
|
+
@log_file = ask_path('log file?', '/var/log/trinidad/trinidad.log')
|
62
|
+
|
63
|
+
daemon = ERB.new(
|
64
|
+
File.read(
|
65
|
+
File.expand_path('../../init.d/trinidad.erb', File.dirname(__FILE__))
|
66
|
+
)
|
67
|
+
).result(binding)
|
68
|
+
|
69
|
+
puts "Moving trinidad to #{@output_path}"
|
70
|
+
tmp_file = "#{@output_path}/trinidad"
|
71
|
+
File.open(tmp_file, 'w') do |file|
|
72
|
+
file.write(daemon)
|
73
|
+
end
|
74
|
+
|
75
|
+
FileUtils.chmod(0744, tmp_file)
|
76
|
+
end
|
77
|
+
|
78
|
+
def configure_windows_service
|
79
|
+
prunsrv = File.join(@jars_path, 'prunsrv.exe')
|
80
|
+
|
81
|
+
command = %Q{//IS//Trinidad --DisplayName="#{@trinidad_name}" \
|
82
|
+
--Install="#{prunsrv}" --Jvm=auto --StartMode=jvm --StopMode=jvm \
|
83
|
+
--StartClass=com.msp.procrun.JRubyService --StartMethod=start \
|
84
|
+
--StartParams="#{@trinidad_daemon_path};#{@trinidad_options.join(";")}" \
|
85
|
+
--StopClass=com.msp.procrun.JRubyService --StopMethod=stop --Classpath="#{@classpath.join(";")}" \
|
86
|
+
--StdOutput=auto --StdError=auto \
|
87
|
+
--LogPrefix="#{@trinidad_name.downcase.gsub(/\W/,'')}" \
|
88
|
+
++JvmOptions="#{@jruby_opts.join(";")}"
|
89
|
+
}
|
90
|
+
system "#{prunsrv} #{command}"
|
91
|
+
end
|
92
|
+
|
93
|
+
private
|
94
|
+
|
95
|
+
def default_jruby_home
|
96
|
+
Java::JavaLang::System.get_property("jruby.home")
|
97
|
+
end
|
98
|
+
|
99
|
+
def default_java_home
|
100
|
+
Java::JavaLang::System.get_property("java.home")
|
101
|
+
end
|
102
|
+
|
103
|
+
def default_ruby_compat_version
|
104
|
+
"RUBY1_8"
|
105
|
+
end
|
106
|
+
|
107
|
+
def windows?
|
108
|
+
RbConfig::CONFIG['host_os'] =~ /mswin|mingw/i
|
109
|
+
end
|
110
|
+
|
111
|
+
def macosx?
|
112
|
+
RbConfig::CONFIG['host_os'] =~ /darwin/i
|
113
|
+
end
|
114
|
+
|
115
|
+
def jsvc_path
|
116
|
+
jsvc = 'jsvc_' + (macosx? ? 'darwin' : 'linux')
|
117
|
+
File.join(@jars_path, jsvc)
|
118
|
+
end
|
119
|
+
|
120
|
+
def ask_path(question, default = nil)
|
121
|
+
File.expand_path(ask(question, default))
|
122
|
+
end
|
123
|
+
|
124
|
+
def ask(question, default = nil)
|
125
|
+
return nil if not @stdin.tty?
|
126
|
+
|
127
|
+
question << " [#{default}]" if default && !default.empty?
|
128
|
+
|
129
|
+
result = nil
|
130
|
+
|
131
|
+
while result.nil?
|
132
|
+
@stdout.print(question + " ")
|
133
|
+
@stdout.flush
|
134
|
+
|
135
|
+
result = @stdin.gets
|
136
|
+
|
137
|
+
if result
|
138
|
+
result.chomp!
|
139
|
+
|
140
|
+
result = case result
|
141
|
+
when /^$/
|
142
|
+
default
|
143
|
+
else
|
144
|
+
result
|
145
|
+
end
|
146
|
+
end
|
147
|
+
end
|
148
|
+
return result
|
149
|
+
end
|
150
|
+
end
|
151
|
+
end
|
152
|
+
end
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -0,0 +1,88 @@
|
|
1
|
+
## This is the rakegem gemspec template. Make sure you read and understand
|
2
|
+
## all of the comments. Some sections require modification, and others can
|
3
|
+
## be deleted if you don't need them. Once you understand the contents of
|
4
|
+
## this file, feel free to delete any comments that begin with two hash marks.
|
5
|
+
## You can find comprehensive Gem::Specification documentation, at
|
6
|
+
## http://docs.rubygems.org/read/chapter/20
|
7
|
+
Gem::Specification.new do |s|
|
8
|
+
s.specification_version = 2 if s.respond_to? :specification_version=
|
9
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
10
|
+
s.rubygems_version = '1.3.5'
|
11
|
+
|
12
|
+
## Leave these as is they will be modified for you by the rake gemspec task.
|
13
|
+
## If your rubyforge_project name is different, then edit it and comment out
|
14
|
+
## the sub! line in the Rakefile
|
15
|
+
s.name = 'trinidad_init_services'
|
16
|
+
s.version = '1.0.0'
|
17
|
+
s.date = '2011-07-12'
|
18
|
+
s.rubyforge_project = 'trinidad_init_services'
|
19
|
+
|
20
|
+
## Make sure your summary is short. The description may be as long
|
21
|
+
## as you like.
|
22
|
+
s.summary = "Trinidad init service scripts based on Apache Commons Daemon"
|
23
|
+
s.description = "Trinidad init service scripts on Apache Commons Daemon and JRuby-jsvc, compatible with Unix and Windows services"
|
24
|
+
|
25
|
+
## List the primary authors. If there are a bunch of authors, it's probably
|
26
|
+
## better to set the email to an email list or something. If you don't have
|
27
|
+
## a custom homepage, consider using your GitHub URL or the like.
|
28
|
+
s.authors = ["David Calavera"]
|
29
|
+
s.email = 'calavera@apache.org'
|
30
|
+
s.homepage = 'http://github.com/calavera/trinidad_daemon'
|
31
|
+
|
32
|
+
## This gets added to the $LOAD_PATH so that 'lib/NAME.rb' can be required as
|
33
|
+
## require 'NAME.rb' or'/lib/NAME/file.rb' can be as require 'NAME/file.rb'
|
34
|
+
s.require_paths = %w[lib]
|
35
|
+
|
36
|
+
## If your gem includes any executables, list them here.
|
37
|
+
s.executables = ["trinidad_init_service"]
|
38
|
+
s.default_executable = 'trinidad_daemon_install'
|
39
|
+
|
40
|
+
## Specify any RDoc options here. You'll want to add your README and
|
41
|
+
## LICENSE files to the extra_rdoc_files list.
|
42
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
43
|
+
s.extra_rdoc_files = %w[README LICENSE]
|
44
|
+
|
45
|
+
## List your runtime dependencies here. Runtime dependencies are those
|
46
|
+
## that are needed for an end user to actually USE your code.
|
47
|
+
s.add_dependency('trinidad', '>=1.2.2')
|
48
|
+
|
49
|
+
## Leave this section as-is. It will be automatically generated from the
|
50
|
+
## contents of your Git repository via the gemspec task. DO NOT REMOVE
|
51
|
+
## THE MANIFEST COMMENTS, they are used as delimiters by the task.
|
52
|
+
# = MANIFEST =
|
53
|
+
s.files = %w[
|
54
|
+
History.txt
|
55
|
+
LICENSE
|
56
|
+
README
|
57
|
+
Rakefile
|
58
|
+
bin/trinidad_init_service
|
59
|
+
init.d/trinidad.erb
|
60
|
+
lib/trinidad_init_services.rb
|
61
|
+
lib/trinidad_init_services/configuration.rb
|
62
|
+
trinidad-libs/commons-daemon.jar
|
63
|
+
trinidad-libs/jruby-jsvc.jar
|
64
|
+
trinidad-libs/jsvc_darwin
|
65
|
+
trinidad-libs/jsvc_linux
|
66
|
+
trinidad-libs/prunsrv.exe
|
67
|
+
trinidad_init_services.gemspec
|
68
|
+
]
|
69
|
+
# = MANIFEST =
|
70
|
+
|
71
|
+
## Test files will be grabbed from the file list. Make sure the path glob
|
72
|
+
## matches what you actually use.
|
73
|
+
## s.test_files = s.files.select { |path| path =~ /^test\/test_.*\.rb/ }
|
74
|
+
|
75
|
+
s.post_install_message = <<TEXT
|
76
|
+
|
77
|
+
------------------------------------------------------------------------------------
|
78
|
+
|
79
|
+
Please now run:
|
80
|
+
|
81
|
+
$ jruby -S trinidad_init_service
|
82
|
+
|
83
|
+
to complete the installation.
|
84
|
+
|
85
|
+
------------------------------------------------------------------------------------
|
86
|
+
|
87
|
+
TEXT
|
88
|
+
end
|
metadata
ADDED
@@ -0,0 +1,91 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: trinidad_init_services
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease:
|
5
|
+
version: 1.0.0
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- David Calavera
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
|
13
|
+
date: 2011-07-12 00:00:00 +02:00
|
14
|
+
default_executable: trinidad_daemon_install
|
15
|
+
dependencies:
|
16
|
+
- !ruby/object:Gem::Dependency
|
17
|
+
name: trinidad
|
18
|
+
prerelease: false
|
19
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
20
|
+
none: false
|
21
|
+
requirements:
|
22
|
+
- - ">="
|
23
|
+
- !ruby/object:Gem::Version
|
24
|
+
version: 1.2.2
|
25
|
+
type: :runtime
|
26
|
+
version_requirements: *id001
|
27
|
+
description: Trinidad init service scripts on Apache Commons Daemon and JRuby-jsvc, compatible with Unix and Windows services
|
28
|
+
email: calavera@apache.org
|
29
|
+
executables:
|
30
|
+
- trinidad_init_service
|
31
|
+
extensions: []
|
32
|
+
|
33
|
+
extra_rdoc_files:
|
34
|
+
- README
|
35
|
+
- LICENSE
|
36
|
+
files:
|
37
|
+
- History.txt
|
38
|
+
- LICENSE
|
39
|
+
- README
|
40
|
+
- Rakefile
|
41
|
+
- bin/trinidad_init_service
|
42
|
+
- init.d/trinidad.erb
|
43
|
+
- lib/trinidad_init_services.rb
|
44
|
+
- lib/trinidad_init_services/configuration.rb
|
45
|
+
- trinidad-libs/commons-daemon.jar
|
46
|
+
- trinidad-libs/jruby-jsvc.jar
|
47
|
+
- trinidad-libs/jsvc_darwin
|
48
|
+
- trinidad-libs/jsvc_linux
|
49
|
+
- trinidad-libs/prunsrv.exe
|
50
|
+
- trinidad_init_services.gemspec
|
51
|
+
has_rdoc: true
|
52
|
+
homepage: http://github.com/calavera/trinidad_daemon
|
53
|
+
licenses: []
|
54
|
+
|
55
|
+
post_install_message: |+
|
56
|
+
|
57
|
+
------------------------------------------------------------------------------------
|
58
|
+
|
59
|
+
Please now run:
|
60
|
+
|
61
|
+
$ jruby -S trinidad_init_service
|
62
|
+
|
63
|
+
to complete the installation.
|
64
|
+
|
65
|
+
------------------------------------------------------------------------------------
|
66
|
+
|
67
|
+
rdoc_options:
|
68
|
+
- --charset=UTF-8
|
69
|
+
require_paths:
|
70
|
+
- lib
|
71
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
72
|
+
none: false
|
73
|
+
requirements:
|
74
|
+
- - ">="
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: "0"
|
77
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
78
|
+
none: false
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: "0"
|
83
|
+
requirements: []
|
84
|
+
|
85
|
+
rubyforge_project: trinidad_init_services
|
86
|
+
rubygems_version: 1.5.1
|
87
|
+
signing_key:
|
88
|
+
specification_version: 2
|
89
|
+
summary: Trinidad init service scripts based on Apache Commons Daemon
|
90
|
+
test_files: []
|
91
|
+
|