trinidad_init_services 1.1.3 → 1.1.4

Sign up to get free protection for your applications and to get access to all the features.
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,39 @@
1
+ /* Licensed to the Apache Software Foundation (ASF) under one or more
2
+ * contributor license agreements. See the NOTICE file distributed with
3
+ * this work for additional information regarding copyright ownership.
4
+ * The ASF licenses this file to You under the Apache License, Version 2.0
5
+ * (the "License"); you may not use this file except in compliance with
6
+ * the License. You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ /* @version $Id: replace.h 921765 2010-03-11 10:03:32Z mturk $ */
18
+ #ifndef __JSVC_REPLACE_H__
19
+ #define __JSVC_REPLACE_H__
20
+
21
+ /**
22
+ * Replace all occurrences of mch in old with the new string rpl, and
23
+ * stores the result in new, provided that its length (specified in len)
24
+ * is enough.
25
+ *
26
+ * @param new The buffer where the result of the replace operation will be
27
+ * stored into.
28
+ * @param len The length of the previous buffer.
29
+ * @param old The string where occurrences of mtch must be searched.
30
+ * @param mch The characters to match in old (and to be replaced)
31
+ * @param rpl The characters that will be replaced in place of mch.
32
+ * @return Zero on success, a value less than 0 if an error was encountered
33
+ * or a value greater than zero (indicating the required storage size
34
+ * for new) if the buffer was too short to hold the new string.
35
+ */
36
+ int replace(char *new, int len, char *old, char *mch, char *rpl);
37
+
38
+ #endif /* ifndef __JSVC_REPLACE_H__ */
39
+
@@ -0,0 +1,105 @@
1
+ /* Licensed to the Apache Software Foundation (ASF) under one or more
2
+ * contributor license agreements. See the NOTICE file distributed with
3
+ * this work for additional information regarding copyright ownership.
4
+ * The ASF licenses this file to You under the Apache License, Version 2.0
5
+ * (the "License"); you may not use this file except in compliance with
6
+ * the License. You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ /* @version $Id: signals.c 982560 2010-08-05 12:05:30Z mturk $ */
18
+
19
+ /*
20
+ * as Windows does not support signal, jsvc uses events to emulate them.
21
+ * The supported signal is SIGTERM.
22
+ * The kills.c contains the kill logic.
23
+ */
24
+ #ifdef OS_CYGWIN
25
+ #include <windows.h>
26
+ #include <stdio.h>
27
+ static void (*HandleTerm) (void) = NULL; /* address of the handler routine. */
28
+
29
+ /*
30
+ * Event handling routine
31
+ */
32
+ void v_difthf(LPVOID par)
33
+ {
34
+ HANDLE hevint; /* make a local copy because the parameter is shared! */
35
+
36
+ hevint = (HANDLE) par;
37
+
38
+ for (;;) {
39
+ if (WaitForSingleObject(hevint, INFINITE) == WAIT_FAILED) {
40
+ /* something have gone wrong. */
41
+ return; /* may be something more is needed. */
42
+ }
43
+
44
+ /* call the interrupt handler. */
45
+ if (HandleTerm == NULL)
46
+ return;
47
+ HandleTerm();
48
+ }
49
+ }
50
+
51
+ /*
52
+ * set a routine handler for the signal
53
+ * note that it cannot be used to change the signal handler
54
+ */
55
+ int SetTerm(void (*func) (void))
56
+ {
57
+ char Name[256];
58
+ HANDLE hevint, hthread;
59
+ DWORD ThreadId;
60
+ SECURITY_ATTRIBUTES sa;
61
+ SECURITY_DESCRIPTOR sd;
62
+
63
+ sprintf(Name, "TERM%ld", GetCurrentProcessId());
64
+
65
+ /*
66
+ * event cannot be inherited.
67
+ * the event is reseted to nonsignaled after the waiting thread is released.
68
+ * the start state is resetted.
69
+ */
70
+
71
+ /* Initialize the new security descriptor. */
72
+ InitializeSecurityDescriptor(&sd, SECURITY_DESCRIPTOR_REVISION);
73
+
74
+ /* Add a NULL descriptor ACL to the security descriptor. */
75
+ SetSecurityDescriptorDacl(&sd, TRUE, (PACL) NULL, FALSE);
76
+
77
+ sa.nLength = sizeof(sa);
78
+ sa.lpSecurityDescriptor = &sd;
79
+ sa.bInheritHandle = TRUE;
80
+
81
+
82
+ /* It works also with NULL instead &sa!! */
83
+ hevint = CreateEvent(&sa, FALSE, FALSE, Name);
84
+
85
+ HandleTerm = func;
86
+
87
+ if (hevint == NULL)
88
+ return -1; /* failed */
89
+
90
+ /* create the thread to wait for event */
91
+ hthread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE) v_difthf,
92
+ (LPVOID) hevint, 0, &ThreadId);
93
+ if (hthread == NULL) {
94
+ /* failed remove the event */
95
+ CloseHandle(hevint); /* windows will remove it. */
96
+ return -1;
97
+ }
98
+
99
+ CloseHandle(hthread); /* not needed */
100
+ return 0;
101
+ }
102
+ #else
103
+ const char __unused_signals_c[] = __FILE__;
104
+ #endif
105
+
@@ -0,0 +1,34 @@
1
+ /*
2
+ Copyright 2001-2004 The Apache Software Foundation.
3
+
4
+ Licensed under the Apache License, Version 2.0 (the "License");
5
+ you may not use this file except in compliance with the License.
6
+ You may obtain a copy of the License at
7
+
8
+ http://www.apache.org/licenses/LICENSE-2.0
9
+
10
+ Unless required by applicable law or agreed to in writing, software
11
+ distributed under the License is distributed on an "AS IS" BASIS,
12
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ See the License for the specific language governing permissions and
14
+ limitations under the License.
15
+ */
16
+ /* @version $Id$ */
17
+ #ifndef __JSVC_SIGNALS_H__
18
+ #define __JSVC_SIGNALS_H__
19
+
20
+ /*
21
+ * as Windows does not support signal, jsvc use event to emulate them.
22
+ * The supported signal is SIGTERM.
23
+ */
24
+ #ifdef OS_CYGWIN
25
+ /*
26
+ * set a routine handler for the signal
27
+ * note that it cannot be used to change the signal handler
28
+ * @param func The function to call on termination
29
+ * @return Zero on success, a value less than 0 if an error was encountered
30
+ */
31
+ int SetTerm(void (*func) (void));
32
+
33
+ #endif
34
+ #endif /* ifndef __JSVC_SIGNALS_H__ */
@@ -0,0 +1,63 @@
1
+ /* Licensed to the Apache Software Foundation (ASF) under one or more
2
+ * contributor license agreements. See the NOTICE file distributed with
3
+ * this work for additional information regarding copyright ownership.
4
+ * The ASF licenses this file to You under the Apache License, Version 2.0
5
+ * (the "License"); you may not use this file except in compliance with
6
+ * the License. You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ #ifndef __VERSION_H__
18
+ #define __VERSION_H__
19
+
20
+ /**
21
+ * Major API changes that could cause compatibility problems for older
22
+ * programs such as structure size changes. No binary compatibility is
23
+ * possible across a change in the major version.
24
+ */
25
+ #define JSVC_MAJOR_VERSION 1
26
+
27
+ /**
28
+ * Minor API changes that do not cause binary compatibility problems.
29
+ * Should be reset to 0 when upgrading JSVC_MAJOR_VERSION
30
+ */
31
+ #define JSVC_MINOR_VERSION 0
32
+
33
+ /** patch level */
34
+ #define JSVC_PATCH_VERSION 10
35
+
36
+ /**
37
+ * This symbol is defined for internal, "development" copies of JSVC.
38
+ * This symbol will be #undef'd for releases.
39
+ */
40
+ #define JSVC_IS_DEV_VERSION 0
41
+
42
+ /** Properly quote a value as a string in the C preprocessor */
43
+ #define JSVC_STRINGIFY(n) JSVC_STRINGIFY_HELPER(n)
44
+ /** Helper macro for JSVC_STRINGIFY */
45
+ #define JSVC_STRINGIFY_HELPER(n) #n
46
+
47
+
48
+ /** The formatted string of APU's version */
49
+ #define JSVC_VERSION_STRING \
50
+ JSVC_STRINGIFY(JSVC_MAJOR_VERSION) "." \
51
+ JSVC_STRINGIFY(JSVC_MINOR_VERSION) "." \
52
+ JSVC_STRINGIFY(JSVC_PATCH_VERSION) \
53
+ JSVC_IS_DEV_STRING
54
+
55
+ /** Internal: string form of the "is dev" flag */
56
+ #if JSVC_IS_DEV_VERSION
57
+ #define JSVC_IS_DEV_STRING "-dev"
58
+ #else
59
+ #define JSVC_IS_DEV_STRING ""
60
+ #endif
61
+
62
+ #endif /* __VERSION_H__ */
63
+
@@ -0,0 +1,110 @@
1
+ dnl
2
+ dnl Licensed to the Apache Software Foundation (ASF) under one or more
3
+ dnl contributor license agreements. See the NOTICE file distributed with
4
+ dnl this work for additional information regarding copyright ownership.
5
+ dnl The ASF licenses this file to You under the Apache License, Version 2.0
6
+ dnl (the "License"); you may not use this file except in compliance with
7
+ dnl the License. You may obtain a copy of the License at
8
+ dnl
9
+ dnl http://www.apache.org/licenses/LICENSE-2.0
10
+ dnl
11
+ dnl Unless required by applicable law or agreed to in writing, software
12
+ dnl distributed under the License is distributed on an "AS IS" BASIS,
13
+ dnl WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ dnl See the License for the specific language governing permissions and
15
+ dnl limitations under the License.
16
+ dnl
17
+
18
+ dnl -------------------------------------------------------------------------
19
+ dnl Author Pier Fumagalli <mailto:pier.fumagalli@eng.sun.com>
20
+ dnl Version $Id: apfunctions.m4 1003756 2010-10-02 08:59:48Z mturk $
21
+ dnl -------------------------------------------------------------------------
22
+
23
+ AC_DEFUN(AP_MSG_HEADER,[
24
+ printf "*** %s ***\n" "$1" 1>&2
25
+ AC_PROVIDE([$0])
26
+ ])
27
+
28
+ AC_DEFUN(AP_CANONICAL_HOST_CHECK,[
29
+ AC_MSG_CHECKING([cached host system type])
30
+ if { test x"${ac_cv_host_system_type+set}" = x"set" &&
31
+ test x"$ac_cv_host_system_type" != x"$host" ; }
32
+ then
33
+ AC_MSG_RESULT([$ac_cv_host_system_type])
34
+ AC_MSG_ERROR([remove the \"$cache_file\" file and re-run configure])
35
+ else
36
+ AC_MSG_RESULT(ok)
37
+ ac_cv_host_system_type="$host"
38
+ fi
39
+ AC_PROVIDE([$0])
40
+ ])
41
+
42
+ dnl Iteratively interpolate the contents of the second argument
43
+ dnl until interpolation offers no new result. Then assign the
44
+ dnl final result to $1.
45
+ dnl
46
+ dnl Example:
47
+ dnl
48
+ dnl foo=1
49
+ dnl bar='${foo}/2'
50
+ dnl baz='${bar}/3'
51
+ dnl AP_EXPAND_VAR(fraz, $baz)
52
+ dnl $fraz is now "1/2/3"
53
+ dnl
54
+ AC_DEFUN([AP_EXPAND_VAR], [
55
+ ap_last=
56
+ ap_cur="$2"
57
+ while test "x${ap_cur}" != "x${ap_last}";
58
+ do
59
+ ap_last="${ap_cur}"
60
+ ap_cur=`eval "echo ${ap_cur}"`
61
+ done
62
+ $1="${ap_cur}"
63
+ ])
64
+
65
+ dnl
66
+ dnl AP_CONFIG_NICE(filename)
67
+ dnl
68
+ dnl Saves a snapshot of the configure command-line for later reuse
69
+ dnl
70
+ AC_DEFUN([AP_CONFIG_NICE], [
71
+ rm -f $1
72
+ cat >$1<<EOF
73
+ #! /bin/sh
74
+ #
75
+ # Created by configure
76
+
77
+ EOF
78
+ if test -n "$CC"; then
79
+ echo "CC=\"$CC\"; export CC" >> $1
80
+ fi
81
+ if test -n "$CFLAGS"; then
82
+ echo "CFLAGS=\"$CFLAGS\"; export CFLAGS" >> $1
83
+ fi
84
+ if test -n "$CPPFLAGS"; then
85
+ echo "CPPFLAGS=\"$CPPFLAGS\"; export CPPFLAGS" >> $1
86
+ fi
87
+ if test -n "$LDFLAGS"; then
88
+ echo "LDFLAGS=\"$LDFLAGS\"; export LDFLAGS" >> $1
89
+ fi
90
+ if test -n "$LIBS"; then
91
+ echo "LIBS=\"$LIBS\"; export LIBS" >> $1
92
+ fi
93
+ if test -n "$STRIPFLAGS"; then
94
+ echo "STRIPFLAGS=\"$STRIPFLAGS\"; export STRIPFLAGS" >> $1
95
+ fi
96
+ if test -n "$INCLUDES"; then
97
+ echo "INCLUDES=\"$INCLUDES\"; export INCLUDES" >> $1
98
+ fi
99
+ # Retrieve command-line arguments.
100
+ eval "set x $[0] $ac_configure_args"
101
+ shift
102
+
103
+ for arg
104
+ do
105
+ AP_EXPAND_VAR(arg, $arg)
106
+ echo "\"[$]arg\" \\" >> $1
107
+ done
108
+ echo '"[$]@"' >> $1
109
+ chmod +x $1
110
+ ])dnl
@@ -0,0 +1,94 @@
1
+ dnl
2
+ dnl Licensed to the Apache Software Foundation (ASF) under one or more
3
+ dnl contributor license agreements. See the NOTICE file distributed with
4
+ dnl this work for additional information regarding copyright ownership.
5
+ dnl The ASF licenses this file to You under the Apache License, Version 2.0
6
+ dnl (the "License"); you may not use this file except in compliance with
7
+ dnl the License. You may obtain a copy of the License at
8
+ dnl
9
+ dnl http://www.apache.org/licenses/LICENSE-2.0
10
+ dnl
11
+ dnl Unless required by applicable law or agreed to in writing, software
12
+ dnl distributed under the License is distributed on an "AS IS" BASIS,
13
+ dnl WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ dnl See the License for the specific language governing permissions and
15
+ dnl limitations under the License.
16
+ dnl
17
+
18
+ dnl -------------------------------------------------------------------------
19
+ dnl Author Pier Fumagalli
20
+ dnl Author Mladen Turk
21
+ dnl Version $Id: apjava.m4 1196262 2011-11-01 20:35:39Z mturk $
22
+ dnl -------------------------------------------------------------------------
23
+
24
+ AC_DEFUN([AP_FIND_JAVA],[
25
+ AC_ARG_WITH(java,[ --with-java=DIR Specify the location of your JDK installation],[
26
+ AC_MSG_CHECKING([JAVA_HOME])
27
+ if test -d "$withval"
28
+ then
29
+ JAVA_HOME="$withval"
30
+ AC_MSG_RESULT([$JAVA_HOME])
31
+ else
32
+ AC_MSG_RESULT([failed])
33
+ AC_MSG_ERROR([$withval is not a directory])
34
+ fi
35
+ AC_SUBST(JAVA_HOME)
36
+ ])
37
+ if test "x$JAVA_HOME" = x
38
+ then
39
+ AC_MSG_CHECKING([for JDK location])
40
+ # Oh well, nobody set JAVA_HOME, have to guess
41
+ # Check if we have java in the PATH.
42
+ java_prog="`which java 2>/dev/null || true`"
43
+ if test "x$java_prog" != x
44
+ then
45
+ java_bin="`dirname $java_prog`"
46
+ java_top="`dirname $java_bin`"
47
+ if test -f "$java_top/include/jni.h"
48
+ then
49
+ JAVA_HOME="$java_top"
50
+ AC_MSG_RESULT([${java_top}])
51
+ fi
52
+ fi
53
+ fi
54
+ if test x"$JAVA_HOME" = x
55
+ then
56
+ AC_MSG_ERROR([Java Home not defined. Rerun with --with-java=[...] parameter])
57
+ fi
58
+ ])
59
+
60
+ AC_DEFUN([AP_FIND_JAVA_OS],[
61
+ tempval=""
62
+ JAVA_OS=""
63
+ AC_ARG_WITH(os-type,[ --with-os-type[=SUBDIR] Location of JDK os-type subdirectory.],
64
+ [
65
+ tempval=$withval
66
+ if test ! -d "$JAVA_HOME/$tempval"
67
+ then
68
+ AC_MSG_ERROR(Not a directory: ${JAVA_HOME}/${tempval})
69
+ fi
70
+ JAVA_OS=$tempval
71
+ ],
72
+ [
73
+ AC_MSG_CHECKING(for JDK os include directory)
74
+ JAVA_OS=NONE
75
+ if test -f $JAVA_HOME/$JAVA_INC/jni_md.h
76
+ then
77
+ JAVA_OS=""
78
+ else
79
+ for f in $JAVA_HOME/$JAVA_INC/*/jni_md.h
80
+ do
81
+ if test -f $f; then
82
+ JAVA_OS=`dirname $f`
83
+ JAVA_OS=`basename $JAVA_OS`
84
+ echo " $JAVA_OS"
85
+ break
86
+ fi
87
+ done
88
+ if test "x$JAVA_OS" = "xNONE"; then
89
+ AC_MSG_RESULT(Cannot find jni_md.h in ${JAVA_HOME}/${OS})
90
+ AC_MSG_ERROR(You should retry --with-os-type=SUBDIR)
91
+ fi
92
+ fi
93
+ ])
94
+ ])