trinidad_init_services 1.1.3 → 1.1.4

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.
Files changed (61) hide show
  1. data/.gitignore +5 -0
  2. data/Gemfile +3 -0
  3. data/History.txt +6 -0
  4. data/README.md +95 -0
  5. data/Rakefile +9 -58
  6. data/bin/trinidad_init_service +3 -4
  7. data/init.d/trinidad.erb +33 -12
  8. data/jsvc-unix-src/CHANGES.txt +62 -0
  9. data/jsvc-unix-src/INSTALL.txt +81 -0
  10. data/jsvc-unix-src/Makedefs.in +32 -0
  11. data/jsvc-unix-src/Makefile.in +42 -0
  12. data/jsvc-unix-src/configure +4417 -0
  13. data/jsvc-unix-src/configure.in +141 -0
  14. data/jsvc-unix-src/man/README +20 -0
  15. data/jsvc-unix-src/man/fetch.sh +36 -0
  16. data/jsvc-unix-src/man/jsvc.1.xml +214 -0
  17. data/jsvc-unix-src/native/.indent.pro +7 -0
  18. data/jsvc-unix-src/native/Makefile.in +46 -0
  19. data/jsvc-unix-src/native/arguments.c +476 -0
  20. data/jsvc-unix-src/native/arguments.h +94 -0
  21. data/jsvc-unix-src/native/debug.c +87 -0
  22. data/jsvc-unix-src/native/debug.h +65 -0
  23. data/jsvc-unix-src/native/dso-dlfcn.c +62 -0
  24. data/jsvc-unix-src/native/dso-dyld.c +153 -0
  25. data/jsvc-unix-src/native/dso.h +38 -0
  26. data/jsvc-unix-src/native/help.c +106 -0
  27. data/jsvc-unix-src/native/help.h +24 -0
  28. data/jsvc-unix-src/native/home.c +265 -0
  29. data/jsvc-unix-src/native/home.h +47 -0
  30. data/jsvc-unix-src/native/java.c +608 -0
  31. data/jsvc-unix-src/native/java.h +35 -0
  32. data/jsvc-unix-src/native/jsvc-unix.c +1267 -0
  33. data/jsvc-unix-src/native/jsvc.h +55 -0
  34. data/jsvc-unix-src/native/location.c +151 -0
  35. data/jsvc-unix-src/native/location.h +29 -0
  36. data/jsvc-unix-src/native/locks.c +52 -0
  37. data/jsvc-unix-src/native/locks.h +40 -0
  38. data/jsvc-unix-src/native/replace.c +121 -0
  39. data/jsvc-unix-src/native/replace.h +39 -0
  40. data/jsvc-unix-src/native/signals.c +105 -0
  41. data/jsvc-unix-src/native/signals.h +34 -0
  42. data/jsvc-unix-src/native/version.h +63 -0
  43. data/jsvc-unix-src/support/apfunctions.m4 +110 -0
  44. data/jsvc-unix-src/support/apjava.m4 +94 -0
  45. data/jsvc-unix-src/support/apsupport.m4 +155 -0
  46. data/jsvc-unix-src/support/buildconf.sh +33 -0
  47. data/jsvc-unix-src/support/config.guess +1371 -0
  48. data/jsvc-unix-src/support/config.sub +1760 -0
  49. data/jsvc-unix-src/support/install.sh +128 -0
  50. data/jsvc-unix-src/support/mkdist.sh +104 -0
  51. data/lib/trinidad/daemon.rb +31 -0
  52. data/lib/trinidad_init_services.rb +2 -30
  53. data/lib/trinidad_init_services/configuration.rb +91 -14
  54. data/lib/trinidad_init_services/version.rb +5 -0
  55. data/spec/spec_helper.rb +5 -6
  56. data/spec/trinidad_daemon_spec.rb +0 -1
  57. data/spec/trinidad_init_services/configuration_spec.rb +34 -1
  58. data/trinidad_init_services.gemspec +14 -51
  59. metadata +146 -87
  60. data/README +0 -63
  61. data/trinidad-libs/jsvc_linux +0 -0
@@ -0,0 +1,5 @@
1
+ pkg
2
+ trinidad-daemon.sh
3
+ .idea
4
+ nbproject
5
+ Gemfile.lock
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source :rubygems
2
+
3
+ gemspec
@@ -1,3 +1,9 @@
1
+ == 1.1.4 (2012-03-01)
2
+
3
+ * JSVC sources packaged along the gem and compiled on demand (@see #6)
4
+ * Improve JRuby's native path detection in generated init.d script
5
+ * Make gem usable with bundler :git => paths
6
+
1
7
  == 1.1.3 (2012-02-20)
2
8
 
3
9
  * Do not ask for a path with $RUN_USER.
@@ -0,0 +1,95 @@
1
+ # Trinidad Init Services
2
+
3
+ Trinidad's init services based on Apache [commons daemon](http://commons.apache.org/daemon/)
4
+ and [jruby-jsvc](https://github.com/nicobrevin/jruby-jsvc). Works on Unix and Windows systems.
5
+
6
+ ## Installation
7
+
8
+ $ jruby -S gem install trinidad_init_services
9
+
10
+ When the gem is installed the user must launch the installation process:
11
+
12
+ $ jruby -S trinidad_init_service
13
+
14
+ This installer guides you through the configuration process and generates a
15
+ init.d script if you are on a unix system or creates the service if you are
16
+ on a windows box.
17
+
18
+ You can optionally provide a configuration file to the trinidad_init_service
19
+ command. An example configuration file might look like this:
20
+
21
+ app_path: "/home/myuser/app"
22
+ trinidad_options: "-e production"
23
+ jruby_home: "/opt/jruby"
24
+ ruby_compat_version: RUBY1_8
25
+ trinidad_name: Trinidad
26
+ jsvc_path: "/usr/bin/jsvc"
27
+ java_home: "/opt/java"
28
+ output_path: "/etc/init.d"
29
+ pid_file: "/tmp/trinidad.pid"
30
+ log_file: "/tmp/trinidad.log"
31
+
32
+ You can then run the installer like so:
33
+
34
+ $ jruby -S trinidad_init_service trinidad_init_config.yml
35
+
36
+ If any of the required options are not provided in the configuration file, then
37
+ the installer will prompt you for them.
38
+
39
+
40
+ ### Unix
41
+
42
+ #### Requirements
43
+
44
+ To run Trinidad as a daemon [jsvc](http://commons.apache.org/daemon/jsvc.html) is
45
+ used. Some distributions provide binary packages of JSVC but not all, for these
46
+ we do bundle JSVC's sources and try to compile the binary during configuration for
47
+ you. However please note that to build JSVC on Unix you will need :
48
+
49
+ * an ANSI-C compliant compiler (GCC is good) and GNU Make
50
+ * Java SDK installed (a JRE installation is not enough)
51
+
52
+ #### Execution
53
+
54
+ When the installation process finishes you can use the script generated to launch
55
+ the server as a daemon with the options start|stop|restart, i.e:
56
+
57
+ $ /etc/init.d/trinidad restart
58
+
59
+ #### Running as a Non-Root User
60
+
61
+ By default, the Trinidad server process will run as the same user that ran the
62
+ `/etc/init.d/trinidad start` command. But the service can be configured to run
63
+ as a different user. The preferred method for doing this is the `run_user:`
64
+ attribute in the configuration YAML (or it's corresponding value at the prompt).
65
+ For example:
66
+
67
+ app_path: "/home/myuser/app"
68
+ trinidad_options: "-e production"
69
+ jruby_home: "/opt/jruby"
70
+ run_user: myuser
71
+ ...
72
+
73
+ This causes the the server to run with non-root privileges (it essentially executes
74
+ as `sudo -u run_user jsvc ...`).
75
+
76
+ On some platforms, however, it may be required that you use the JSVC `-user` argument.
77
+ This can be configured with the `JSVC_ARGS_EXTRA` environment variable, like this:
78
+
79
+ JSVC_ARGS_EXTRA="-user myuser" /etc/init.d/trinidad start
80
+
81
+ It not recommended that you mix the `-user` flag with the `run_user` option !
82
+
83
+
84
+ ### Windows
85
+
86
+ #### Execution
87
+
88
+ Open the **Services** panel under **Administrative Tools** and look for a service
89
+ called **Trinidad**.
90
+
91
+
92
+ ## Copyright
93
+
94
+ Copyright (c) 2011-2012 David Calavera<calavera@apache.org>.
95
+ See LICENSE for details.
data/Rakefile CHANGED
@@ -12,17 +12,11 @@ def name
12
12
  @name ||= Dir['*.gemspec'].first.split('.').first
13
13
  end
14
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
15
+ $:.push File.expand_path("../lib", __FILE__)
23
16
 
24
- def rubyforge_project
25
- name
17
+ def version
18
+ require 'trinidad_init_services/version'
19
+ Trinidad::InitServices::VERSION
26
20
  end
27
21
 
28
22
  def gemspec_file
@@ -33,31 +27,17 @@ def gem_file
33
27
  "#{name}-#{version}.gem"
34
28
  end
35
29
 
36
- def replace_header(head, header_name)
37
- head.sub!(/(\.#{header_name}\s*= ').*'/) { "#{$1}#{send(header_name)}'"}
38
- end
39
-
40
30
  #############################################################################
41
31
  #
42
32
  # Standard tasks
43
33
  #
44
34
  #############################################################################
45
35
 
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
36
+ task :default => :spec
54
37
 
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"
38
+ require 'rspec/core/rake_task'
39
+ RSpec::Core::RakeTask.new(:spec) do |spec|
40
+ spec.rspec_opts = ['--color', "--format documentation"]
61
41
  end
62
42
 
63
43
  require 'rake/rdoctask'
@@ -101,7 +81,7 @@ task :release => :build do
101
81
  end
102
82
 
103
83
  desc 'Build gem'
104
- task :build => :gemspec do
84
+ task :build => :validate do
105
85
  sh "mkdir -p pkg"
106
86
  sh "gem build #{gemspec_file}"
107
87
  sh "mv #{gem_file} pkg"
@@ -112,35 +92,6 @@ task :install => :build do
112
92
  sh "gem install pkg/#{gem_file}"
113
93
  end
114
94
 
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
95
  task :validate do
145
96
  libfiles = Dir['lib/*'] - ["lib/#{name}.rb", "lib/#{name}"]
146
97
  unless libfiles.empty?
@@ -1,11 +1,10 @@
1
1
  #!/usr/bin/env jruby
2
2
 
3
- require 'trinidad_init_services/configuration'
4
- require 'yaml'
3
+ require 'trinidad_init_services'
5
4
 
6
5
  if ARGV.size > 0
7
- config_file = File.read(ARGV[0])
8
- config = YAML.load(config_file)
6
+ require 'yaml'
7
+ config = YAML.load File.read(ARGV[0])
9
8
  Trinidad::InitServices::Configuration.new.configure(config)
10
9
  else
11
10
  Trinidad::InitServices::Configuration.new.configure
@@ -10,8 +10,6 @@
10
10
  # Things you can set:
11
11
  # PROG_OPTS - Arguments to send to the program. A few defaults are appended to this.
12
12
 
13
- # Path to the jsvc binary, if you're having issues with the pre-compiled binary
14
- # try installing it (e.g. apt-get install jsvc) or compiling it yourself :
15
13
  # https://github.com/trinidad/trinidad_init_services/wiki/Installing-JSVC
16
14
  JSVC=<%= @jsvc %>
17
15
  JAVA_HOME=<%= @java_home %>
@@ -43,18 +41,42 @@ if [ -z "$JRUBY_OPTS" ] ; then
43
41
  JRUBY_OPTS=""
44
42
  fi
45
43
 
46
- # TODO: Allow configuration or detect from the OS
47
- JAVA_NATIVE_PROPS="-Djna.boot.library.path=$JRUBY_HOME/lib/native/linux-i386:$JRUBY_HOME/lib/native/linux-amd64 \
48
- -Djffi.boot.library.path=$JRUBY_HOME/lib/native/i386-Linux:$JRUBY_HOME/lib/native/s390x-Linux:$JRUBY_HOME/lib/native/x86_64-Linux"
44
+ JRUBY_SHELL=/bin/sh
45
+
46
+ JRUBY_NATIVE_PATH=""
47
+ if [ -d "$JRUBY_HOME/lib/native/" ]; then
48
+ for d in $JRUBY_HOME/lib/native/*`uname -s`; do
49
+ if [ -z "$JRUBY_NATIVE_PATH" ]; then
50
+ JRUBY_NATIVE_PATH="$d"
51
+ else
52
+ JRUBY_NATIVE_PATH="$JRUBY_NATIVE_PATH:$d"
53
+ fi
54
+ done
55
+ fi
56
+
57
+ if [ -z "$JAVA_MEM" ] ; then
58
+ JAVA_MEM=500m
59
+ fi
60
+
61
+ if [ -z "$JAVA_STACK" ] ; then
62
+ JAVA_STACK=2048k
63
+ fi
64
+
65
+ JAVA_OPTS="-Xmx${JAVA_MEM} -Xss${JAVA_STACK} -Xbootclasspath/a:$JRUBY_HOME/lib/jruby.jar"
49
66
 
50
- JAVA_PROPS="$JAVA_PROPS -Djruby.memory.max=500m \
51
- -Djruby.stack.max=1024k \
52
- $JAVA_NATIVE_PROPS \
53
- -Djruby.shell=/bin/sh \
67
+ # force file.encoding to UTF-8 :
68
+ if [[ -z "$JAVA_ENCODING" ]]; then
69
+ JAVA_OPTS="${JAVA_OPTS} -Dfile.encoding=UTF-8"
70
+ fi
71
+
72
+ JAVA_PROPS="$JAVA_PROPS \
73
+ -Djruby.memory.max=$JAVA_MEM \
74
+ -Djruby.stack.max=$JAVA_STACK \
75
+ -Djruby.shell=$JRUBY_SHELL \
76
+ -Djffi.boot.library.path=$JRUBY_NATIVE_PATH \
54
77
  <%= @jruby_opts.join(' ') %> \
55
78
  $JRUBY_OPTS"
56
-
57
- JAVA_OPTS="-Xmx500m -Xss1024k -Xbootclasspath/a:$JRUBY_HOME/lib/jruby.jar"
79
+
58
80
  PROC_NAME=${SCRIPT_NAME:-${APP_NAME:-"trinidad"}}
59
81
 
60
82
  JSVC_ARGS="-home $JAVA_HOME \
@@ -139,4 +161,3 @@ case "$1" in
139
161
  echo "Unrecognised command. Usage trinidad [ start | stop | restart ]"
140
162
  ;;
141
163
  esac
142
-
@@ -0,0 +1,62 @@
1
+ APACHE COMMONS DAEMON (UNIX) CHANGELOG:
2
+
3
+ Changes with 1.0.10
4
+ * Fix dynamic libcap loading for some linux ditributions (DAEMON-242)
5
+
6
+ Changes with 1.0.9
7
+ * Dynamically load libcap on linux (DAEMON-234)
8
+
9
+ Changes with 1.0.8
10
+ * Better detection of JDK (DAEMON-220)
11
+ * Use CPPFLAGS in makefile (DAEMON-223)
12
+ * Add -umask parameter (DAEMON-221)
13
+ * Add /etc/alternatives to the location search (DAEMON-224)
14
+
15
+ Changes with 1.0.7
16
+
17
+
18
+ Changes with 1.0.6
19
+ * Fix syslog infinite loop (DAEMON-194)
20
+ * Fix syslog invalid descriptors (DAEMON-186)
21
+
22
+ Changes with 1.0.5
23
+
24
+
25
+ Changes with 1.0.4
26
+ * Add DaemonWrapper to allow running standard applications
27
+ as daemons. (DAEMON-180)
28
+ * Support log rotation using SIGUSR1 (DAEMON-95)
29
+ * Fix FreeBSD build (DAEMON-171)
30
+ * Add support for config.nice and strip utility (DAEMON-176)
31
+
32
+ Changes with 1.0.3
33
+ * Implement fail() method (DAEMON-128)
34
+ * Add missing Java6 parameters (DAEMON-140)
35
+
36
+ Changes with 1.0.2
37
+ * Allow support for OS/X 10.6 (DAEMON-129)
38
+ * Prunmgr shows wrong default logging level (DAEMON-132)
39
+ * Allon non ASCII characters in classpath (DAEMON-130)
40
+ * Log on tab of Prunmgr ignores current settings (DAEMON-126)
41
+ * Unable to open directory /proc/self/fd (DAEMON-120)
42
+ * Read Java parameters for Java mode in the same way as JVM mode (DAEMON-119)
43
+ * Allow running jsvc should as non root (DAEMON-93)
44
+ * Support all the standard Java 5 launcher options (DAEMON-84)
45
+ * Support compilation on Cygwin (DAEMON-40)
46
+ * Add Support for AIX (DAEMON-123)
47
+ * Fix default log path (DAEMON-116)
48
+ * Wait for JVM clean exit (DAEMON-97)
49
+
50
+ Changes with 1.0.1
51
+ * Allow enableassertions -ea (PR 304310).
52
+ * Add -lpthread to LDFLAGS on Linux (PR 30177).
53
+ * Add support for x86_64 (PR 27523).
54
+ * Add support for Tru64 (PR 29465).
55
+ * Remove the pid file when son exits correctly (PR 31614).
56
+ * Add support for JVM-4.1.x on MAC OS X (part of PR 31613).
57
+ * Prevent starting jsvc several times with the same pidfile (PR 33580).
58
+ * Finish fixing 31613, automatic detection of JAVA_HOME and headers locations.
59
+ * -wait and -stop parameters.
60
+ * fix 34851.
61
+ * Don't break when set_caps() failed and the user is unchanged (linux).
62
+
@@ -0,0 +1,81 @@
1
+ To build the service libraries and binary under an UNIX operating
2
+ system you will need:
3
+
4
+ An ANSI-C compliant compiler (GCC is good)
5
+ A Java Platform 2 compliant SDK
6
+ GNU AutoConf (when building for SVN).
7
+
8
+ When building from SVN sources you need to build the "configure" program with:
9
+
10
+ sh support/buildconf.sh
11
+ (Note it is possible to replace sh by any compatible shell like bash, ksh).
12
+
13
+ Once the configure script is generated, run it (remember to specify
14
+ either the --with-java=<dir> parameter or set the JAVA_HOME environment
15
+ to point to your JDK installation. For example:
16
+
17
+ ./configure --with-java=/usr/java
18
+
19
+ or
20
+
21
+ JAVA_HOME=/usr/java
22
+ export JAVA_HOME
23
+ ./configure
24
+
25
+ Note: On Mac OS X <dir> is /System/Library/Frameworks/JavaVM.framework/Home.
26
+
27
+ Depending on your JDK layout, configure might fail to find the JNI
28
+ machine dependant include file (jni_md.h). If that's the case use the
29
+ --with-os-type=<subdir> parameter where subdir points to the directory
30
+ within JDK include directory containing jni_md.h file.
31
+
32
+
33
+ If your operating system is supported, configure will go thru cleanly,
34
+ otherwise it will report an error (please send us the details of your
35
+ OS/JDK, or a patch against the sources).
36
+
37
+ To build the binaries and libraries simply do:
38
+
39
+ make
40
+
41
+ This will generate the file: ./jsvc.
42
+ It should be straightforward from here on. To check the allowed parameters
43
+ for the jsvc binary simply do
44
+
45
+ ./native/jsvc -help
46
+
47
+ Note: On Linux the module capabilities should be loaded, when using -user root
48
+ make sure you REALLY understand what capabilities does (for example for
49
+ files access: the downgraded root may not be able to read some files!).
50
+
51
+ Making 64-bit binaries
52
+
53
+ To be able to build the 64-binaries for supported platforms enter the
54
+ specific parameters before calling configure
55
+
56
+ export CFLAGS=-m64
57
+ export LDFLAGS=-m64
58
+ ./configure
59
+ make
60
+
61
+ Making Universal binaries
62
+
63
+ Some platforms like Mac OSX allow universal or fat binaries that allow
64
+ both 32 and 64 binaries inside the same executable. To be able to build
65
+ the fat binaries enter the specific parameters before calling configure
66
+
67
+ export CFLAGS="-arch i386 -arch x86_64"
68
+ export LDFLAGS="-arch i386 -arch x86_64"
69
+ ./configure
70
+ make
71
+
72
+ Optional Build flags
73
+
74
+ Make process allows specifying additional compilation flags at compile time
75
+ by using EXTRA_CFLAGS and EXTRA_LDFLAGS either as environment variables
76
+ or defined along the make command line
77
+
78
+ make EXTRA_CFLAGS="-march=i586"
79
+
80
+ will cause -march=i586 to be added to the configure generated CFLAGS.
81
+ The same applies to EXTRA_LDFLAGS which will be added at link stage.
@@ -0,0 +1,32 @@
1
+ #
2
+ # Licensed to the Apache Software Foundation (ASF) under one or more
3
+ # contributor license agreements. See the NOTICE file distributed with
4
+ # this work for additional information regarding copyright ownership.
5
+ # The ASF licenses this file to You under the Apache License, Version 2.0
6
+ # (the "License"); you may not use this file except in compliance with
7
+ # the License. You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+ #
17
+
18
+ # @author Pier Fumagalli <mailto:pier.fumagalli@eng.sun.com>
19
+ # @version $Id: Makedefs.in 1194902 2011-10-29 15:19:18Z mturk $
20
+
21
+ CC = @CC@
22
+ CFLAGS = @CFLAGS@
23
+ CPPFLAGS = @CPPFLAGS@
24
+ INCLUDES = @INCLUDES@
25
+ LDFLAGS = @LDFLAGS@
26
+ LIBS = @LIBS@
27
+ RANLIB = @RANLIB@
28
+ LDCMD = @LDCMD@
29
+ STRIP = @STRIP@
30
+
31
+ .c.o:
32
+ $(CC) $(CFLAGS) $(CPPFLAGS) $(EXTRA_CFLAGS) $(INCLUDES) -c $< -o $@