mcconnell 2003/03/07 22:51:04
Modified: merlin build.xml default.properties
merlin/src/config kernel.xml
merlin/src/java/org/apache/avalon/merlin/kernel/impl
DefaultKernel.java
Added: merlin/lib Wrapper.dll wrapper.jar
merlin/src/bin InstallService-NT.bat UninstallService-NT.bat
Wrapper.exe
merlin/src/config kernel-service.xml wrapper.conf
Log:
Addition of resources supporting execution of Merlin as a NT Service. This is a
initial commit and will be updated to support parameterization of multiple deployment
targets.
Revision Changes Path
1.28 +2 -0 avalon-sandbox/merlin/build.xml
Index: build.xml
===================================================================
RCS file: /home/cvs/avalon-sandbox/merlin/build.xml,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -r1.27 -r1.28
--- build.xml 7 Mar 2003 08:54:40 -0000 1.27
+++ build.xml 8 Mar 2003 06:51:03 -0000 1.28
@@ -376,6 +376,8 @@
<mkdir dir="${merlin.home}/lib/system"/>
<mkdir dir="${merlin.home}/lib/shared"/>
<mkdir dir="${merlin.home}/repository"/>
+ <copy toDir="${merlin.home}/lib" file="${wrapper.dll}"/>
+ <copy toDir="${merlin.home}/lib" file="${wrapper.jar}"/>
<copy toDir="${merlin.home}/lib/shared" file="${avalon-framework.jar}"/>
<copy toDir="${merlin.home}/lib/system" file="${excalibur-i18n.jar}"/>
<copy toDir="${merlin.home}/lib/system" file="${excalibur-configuration.jar}"/>
1.25 +4 -0 avalon-sandbox/merlin/default.properties
Index: default.properties
===================================================================
RCS file: /home/cvs/avalon-sandbox/merlin/default.properties,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -r1.24 -r1.25
--- default.properties 7 Mar 2003 08:39:41 -0000 1.24
+++ default.properties 8 Mar 2003 06:51:03 -0000 1.25
@@ -162,6 +162,10 @@
merlin-spi.jar=${local.repository}/${merlin-spi.name}
merlin-spi.path=${remote.repository}/${merlin.family}/jars/${merlin-spi.name}
+# ----- Wrapper -----
+wrapper.dll = ${lib.dir}/Wrapper.dll
+wrapper.jar = ${lib.dir}/wrapper.jar
+
# --------------------------------------------------
# Settings used to configure compile environment
1.1 avalon-sandbox/merlin/lib/Wrapper.dll
<<Binary file>>
1.1 avalon-sandbox/merlin/lib/wrapper.jar
<<Binary file>>
1.1 avalon-sandbox/merlin/src/bin/InstallService-NT.bat
Index: InstallService-NT.bat
===================================================================
@echo off
rem
rem Find the application home.
rem
if "%OS%"=="Windows_NT" goto nt
echo This is not NT, so please edit this script and set _APP_HOME manually
set _APP_HOME=..
goto conf
:nt
rem %~dp0 is name of current script under NT
set _APP_HOME=%~dp0
rem : operator works similar to make : operator
set _APP_HOME=%_APP_HOME:\bin\=%
rem
rem Find the wrapper.conf
rem
:conf
set _WRAPPER_CONF="%~f1"
if not %_WRAPPER_CONF%=="" goto startup
set _WRAPPER_CONF="%_APP_HOME%\config\wrapper.conf"
rem
rem Run the application.
rem At runtime, the current directory will be that of Wrapper.exe
rem
:startup
"%_APP_HOME%\bin\Wrapper.exe" -i %_WRAPPER_CONF%
if not errorlevel 1 goto end
pause
:end
set _APP_HOME=
set _WRAPPER_CONF=
1.1 avalon-sandbox/merlin/src/bin/UninstallService-NT.bat
Index: UninstallService-NT.bat
===================================================================
@echo off
rem
rem Find the application home.
rem
if "%OS%"=="Windows_NT" goto nt
echo This is not NT, so please edit this script and set _APP_HOME manually
set _APP_HOME=..
goto conf
:nt
rem %~dp0 is name of current script under NT
set _APP_HOME=%~dp0
rem : operator works similar to make : operator
set _APP_HOME=%_APP_HOME:\bin\=%
rem
rem Find the wrapper.conf
rem
:conf
set _WRAPPER_CONF="%~f1"
if not %_WRAPPER_CONF%=="" goto startup
set _WRAPPER_CONF="%_APP_HOME%\config\wrapper.conf"
rem
rem Run the application.
rem At runtime, the current directory will be that of Wrapper.exe
rem
:startup
"%_APP_HOME%\bin\Wrapper.exe" -r %_WRAPPER_CONF%
if not errorlevel 1 goto end
pause
:end
set _APP_HOME=
set _WRAPPER_CONF=
1.1 avalon-sandbox/merlin/src/bin/Wrapper.exe
<<Binary file>>
1.3 +1 -1 avalon-sandbox/merlin/src/config/kernel.xml
Index: kernel.xml
===================================================================
RCS file: /home/cvs/avalon-sandbox/merlin/src/config/kernel.xml,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- kernel.xml 27 Feb 2003 23:41:45 -0000 1.2
+++ kernel.xml 8 Mar 2003 06:51:03 -0000 1.3
@@ -23,7 +23,7 @@
<logging target="default" priority="INFO">
<category name="/sys/logger" priority="WARN"/>
<target name="kernel">
- <file location="kernel.log" />
+ <file location="logs/kernel.log" />
</target>
</logging>
1.1 avalon-sandbox/merlin/src/config/kernel-service.xml
Index: kernel-service.xml
===================================================================
<!--
kernel-service.xml
The kernel-process.xml file contains the definition of a Merlin kernel. The kernel
can contain the following declarations:
1. a system descriptor that declares the hostname of this machine
2. a logging descriptor for establishment of the logging subsystem
3. a logging catagories descriptor that establishes logging priority
for the kernel
4. an engine descriptor used to configure the pool
Once a kernel is established the controlling application supplies one or block
configurations to the kernel for deployment.
-->
<kernel>
<system host="localhost"/>
<!-- logging system parameters -->
<logging target="kernel" priority="INFO">
<category name="/sys/logger" priority="WARN"/>
<target name="kernel">
<file location="logs/kernel.log" />
</target>
</logging>
<!-- logging categories for the kernel -->
<categories>
<category name="/sys" priority="INFO"/>
</categories>
<!-- root engine -->
<engine>
<!-- The shared extension directory. -->
<library scope="system" dir="." >
<include name="ext"/>
</library>
<!-- Setup the thread, command and pool manager parameters. -->
<pool>
<threads-per-processor>2</threads-per-processor>
<sleep>1000</sleep>
<timeout>250</timeout>
</pool>
</engine>
</kernel>
1.1 avalon-sandbox/merlin/src/config/wrapper.conf
Index: wrapper.conf
===================================================================
#********************************************************************
# Wrapper parameters
#********************************************************************
# Java Application
wrapper.java.command=java
# Java Main class
wrapper.java.mainclass=org.tanukisoftware.wrapper.WrapperSimpleApp
# Java Classpath (include wrapper.jar) Add class path elements as
# needed starting from 1
wrapper.java.classpath.1=../lib/wrapper.jar
wrapper.java.classpath.2=../lib/system/merlin-bootstrap-1.0.jar
# Java Library Path (location of Wrapper.DLL or libwrapper.so)
wrapper.java.library.path.1=../lib
# Java Additional Parameters
#wrapper.java.additional.1=
# Initial Java Heap Size (in MB)
wrapper.java.initmemory=3
# Maximum Java Heap Size (in MB)
wrapper.java.maxmemory=64
# Application parameters. Add parameters as needed starting from 1
wrapper.app.parameter.1=Merlin
wrapper.app.parameter.2=-system ./..
wrapper.app.parameter.3=-kernel ./../config/kernel-service.xml
wrapper.app.parameter.4=-home ./..
wrapper.app.parameter.5=./../repository/demo/block.xml
# Port which the native wrapper code will attempt to connect to
wrapper.port=1777
#********************************************************************
# Wrapper Logging parameters
#********************************************************************
# Format of output for the console. (See docs for formats)
wrapper.console.format=PM
# Log Level for console output. (See docs for log levels)
wrapper.console.loglevel=INFO
# Log file to use for wrapper output logging.
wrapper.logfile=../logs/wrapper.log
# Format of output for the log file. (See docs for formats)
wrapper.logfile.format=LPTM
# Log Level for log file output. (See docs for log levels)
wrapper.logfile.loglevel=DEBUG
# Maximum size that the log file will be allowed to grow to before
# the log is rolled. Size is specified in bytes. The default value
# of 0, disables log rolling. May abbreviate with the 'k' (kb) or
# 'm' (mb) suffix. For example: 10m = 10 megabytes.
wrapper.logfile.maxsize=0
# Maximum number of rolled log files which will be allowed before old
# files are deleted. The default value of 0 implies no limit.
wrapper.logfile.maxfiles=0
# Log Level for sys/event log output. (See docs for log levels)
wrapper.syslog.loglevel=NONE
#********************************************************************
# Wrapper NT Service parameters
#********************************************************************
# WARNING - Do not modify any of these parameters when an application
# using this configuration file has been installed as a service.
# Please uninstall the service before modifying this section. The
# service can then be reinstalled.
# Name of the service
wrapper.ntservice.name=merlin
# Display name of the service
wrapper.ntservice.displayname=Merlin Service Manager 2.1
# Description of the service
wrapper.ntservice.description=Avalon Merlin Service Management Platform.
# Service dependencies. Add dependencies as needed starting from 1
wrapper.ntservice.dependency.1=
# Mode in which the service is installed. AUTO_START or DEMAND_START
wrapper.ntservice.starttype=AUTO_START
# Priority at which the service is run. NORMAL, LOW, HIGH, or
# REALTIME
wrapper.ntservice.process_priority=NORMAL
# Allow the service to interact with the desktop.
wrapper.ntservice.interactive=false
1.17 +70 -15
avalon-sandbox/merlin/src/java/org/apache/avalon/merlin/kernel/impl/DefaultKernel.java
Index: DefaultKernel.java
===================================================================
RCS file:
/home/cvs/avalon-sandbox/merlin/src/java/org/apache/avalon/merlin/kernel/impl/DefaultKernel.java,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -r1.16 -r1.17
--- DefaultKernel.java 6 Mar 2003 23:23:15 -0000 1.16
+++ DefaultKernel.java 8 Mar 2003 06:51:03 -0000 1.17
@@ -305,7 +305,7 @@
* <td>The url to a configuration overide file. This entry is optional.</td>
* </tr>
* <tr>
- * <td><code>urn:merlin:block.debug</code></td>
+ * <td><code>urn:merlin:debug</code></td>
* <td>[EMAIL PROTECTED] java.lang.String}</td>
* <td>The system logging priority (a value of INFO, WARN, ERROR, or
DEBUG.</td>
* </tr>
@@ -322,7 +322,6 @@
if( context.hasEntry( "urn:merlin:debug" ) )
{
m_debug = (String) context.get( "urn:merlin:debug" );
- System.out.println("### DEBUG: " + m_debug );
}
//
@@ -379,6 +378,8 @@
throw new IllegalStateException("context");
}
+ setShutdownHook( this );
+
//
// Setup the logging system
//
@@ -388,11 +389,17 @@
final String sys = "/sys";
if( m_logging == null )
{
- m_logging = bootstrapLoggingManager( Container.PATH_SEPERATOR, sys,
m_debug );
+ m_logging = bootstrapLoggingManager( Container.PATH_SEPERATOR, sys,
null );
Configuration categoriesConfig = m_config.getChild( "categories" );
+
+ //
+ // setup the kernel logging channels
+ //
+
LoggingDirective categories =
CREATOR.createLoggingDirective(
- Container.PATH_SEPERATOR, categoriesConfig );
+ Container.PATH_SEPERATOR, m_debug, categoriesConfig );
+
m_logging.addCategories( Container.PATH_SEPERATOR, categories );
}
m_local = m_logging.getLoggerForCategory( sys );
@@ -485,6 +492,7 @@
}
}
+
//==============================================================
// Kernel
//==============================================================
@@ -519,6 +527,7 @@
}
Block block = null;
+
try
{
block = m_installer.install( base, config );
@@ -559,8 +568,12 @@
if( getLogger().isDebugEnabled() )
{
StringBuffer buffer = new StringBuffer( "listing declared hierachy\n" );
+
+ //
// list the block URLs
- URL[] urls = m_block.getURLs();
+ //
+
+ URL[] urls = block.getURLs();
for( int i=0; i<urls.length; i++ )
{
buffer.append( "\n " + urls[i].toString() );
@@ -638,8 +651,18 @@
// internals
//==============================================================
+ /**
+ * Creation of the bootstrap logging manager.
+ *
+ * @param root the root logging channel
+ * @param system the logging catagery for logging related messages
+ * @param level the default logging priority
+ * @return the logging manager
+ * @exception Exception if a logging manager establishment error occurs
+ */
private LoggingManager bootstrapLoggingManager(
- String root, String system, String level ) throws Exception
+ String root, String system, String level )
+ throws Exception
{
if( m_config == null )
@@ -772,21 +795,24 @@
public String toString()
{
StringBuffer buffer = new StringBuffer( "DefaultKernel: " +
System.identityHashCode( this ) );
- try
+
+ Block[] blocks = (Block[]) m_blocks.toArray( new Block[0] );
+ buffer.append( "\nBlock count: " + blocks.length );
+ for( int j=0; j<blocks.length; j++ )
{
+ Block block = blocks[j];
+ buffer.append( "\nBlock: " + block );
+
// list the block URLs
- URL[] urls = m_block.getURLs();
+
+ URL[] urls = block.getURLs();
for( int i=0; i<urls.length; i++ )
{
- buffer.append( "\n" + urls[i].toString() );
+ buffer.append( "\n " + urls[i].toString() );
}
buffer.append( "\n" );
- return buffer.toString();
- }
- catch( Throwable e )
- {
- return "DefaultKernel: " + System.identityHashCode( this );
}
+ return buffer.toString();
}
/**
@@ -849,5 +875,34 @@
"Internal error during establishment of the default pool manager.
Cause: ";
throw new Exception( error + e.toString() );
}
+ }
+
+ /**
+ * Create a shutdown hook that will trigger shutdown of the supplied kernel.
+ * @param kernel the kernel to be shutdown
+ */
+ private void setShutdownHook( final Kernel kernel )
+ {
+ //
+ // Create a shutdown hook to trigger clean disposal of the
+ // Merlin kernel
+ //
+
+ Runtime.getRuntime().addShutdownHook(
+ new Thread()
+ {
+ public void run()
+ {
+ try
+ {
+ kernel.shutdown();
+ }
+ catch( Throwable e )
+ {
+ // ignore it
+ }
+ }
+ }
+ );
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]