<!--
   - Resin 3.1 configuration file.
  -->
<resin xmlns="http://caucho.com/ns/resin"
       xmlns:resin="http://caucho.com/ns/resin/core">

	<!-- adds all .jar files under the resin/lib directory -->
	<class-loader>
		<tree-loader path="${resin.home}/lib"/>
		<tree-loader path="${server.root}/lib"/>
	</class-loader>

	<!--
		  - Management configuration
		 -->
	<management path="${server.root}/admin">
	</management>

	<!--
		  - Logging configuration for the JDK logging API.
		 -->
	<log name="" path="stdout:" timestamp="[%H:%M:%S.%s] "/>

	<!--
		  - 'info' for production
		  - 'fine' or 'finer' for development and troubleshooting
		 -->
	<logger name="com.caucho" level="info"/>

	<logger name="com.caucho.java" level="config"/>
	<logger name="com.caucho.loader" level="config"/>

	<!--
		  - For production sites, change dependency-check-interval to something
		  - like 600s, so it only checks for updates every 10 minutes.
		 -->
	<dependency-check-interval>2s</dependency-check-interval>

	<!--
		  - You can change the compiler to "javac", "eclipse" or "internal".
		 -->
	<javac compiler="internal" args="-source 1.6"/>

	<!--
		  - Configuration for the web-tier/load-balancer
		 -->
	<cluster id="web-tier">

		<server-default>
			<!-- The http port -->
			<http address="*" port="80"/>
		</server-default>

		<server id="web-a" address="127.0.0.1"/>

		<cache path="cache" memory-size="64M"/>

		<host id="" root-directory="webapps">
			<web-app id="/">

				<rewrite-dispatch>
					<load-balance regexp="" cluster="app-tier"/>
				</rewrite-dispatch>

			</web-app>
		</host>
	</cluster>

	<cluster id="app-tier">
		<!-- sets the content root for the cluster, relative to server.root -->
		<root-directory>webapps</root-directory>

		<server-default>
			<!-- The http port -->
			<!--<http address="*" port="80"/>-->

			<!--
				  - The JVM arguments
				 -->
			<jvm-arg>-Xmx768m</jvm-arg>
			<jvm-arg>-Xms768m</jvm-arg>
			<jvm-arg>-XX:MaxPermSize=256m</jvm-arg>
			<jvm-arg>-Xss1m</jvm-arg>
			<jvm-arg>-Xdebug</jvm-arg>
			<jvm-arg>-Dcom.sun.management.jmxremote</jvm-arg>
			<jvm-arg>-Dcom.sun.management.jmxremote.port=51001</jvm-arg>
			<jvm-arg>-Dcom.sun.management.jmxremote.ssl=false</jvm-arg>
			<jvm-arg>-Dcom.sun.management.jmxremote.authenticate=false</jvm-arg>

			<!--
				  - Uncomment to enable admin heap dumps-->
			<!--<jvm-arg>-agentlib:resin</jvm-arg>-->

			<watchdog-arg>-Dcom.sun.management.jmxremote</watchdog-arg>

			<!--
				  - Configures the minimum free memory allowed before Resin
				  - will force a restart.
				 -->
			<memory-free-min>1M</memory-free-min>

			<!-- Maximum number of threads. -->
			<thread-max>256</thread-max>

			<!-- Configures the socket timeout -->
			<socket-timeout>65s</socket-timeout>

			<!-- Configures the keepalive -->
			<keepalive-max>128</keepalive-max>
			<keepalive-timeout>15s</keepalive-timeout>

			

			<!--
				  - If starting bin/resin as root on Unix, specify the user name
				  - and group name for the web server user.
				  -
				  - <user-name>resin</user-name>
				  - <group-name>resin</group-name>
				 -->
		</server-default>

		<!-- define the servers in the cluster -->
		<server id="app-a" address="app-a" port="6800"/>
		<server id="app-b" address="app-b" port="6800"/>

		<!--
				 - Configures the persistent store for single-server or clustered
				 - in Resin professional.
				-->
		<persistent-store type="cluster">
			<init path="${resin.home}/cluster"/>
		</persistent-store>

		<!--
				 - For security, use a different cookie for SSL sessions.
				 - <ssl-session-cookie>SSL_JSESSIONID</ssl-session-cookie>
				-->

		<!--
				 - Enables the cache (available in Resin Professional)
				-->
		<cache path="cache" memory-size="64M">
			<!-- Vary header rewriting for IE -->
			<rewrite-vary-as-private/>
		</cache>

		<!-- includes the app-default for default web-app behavior -->
		<resin:import path="${resin.home}/conf/app-default.xml"/>

		<!--
				 - Defaults applied to each web-app.
				-->
		<web-app-default>
			<!--
						- Extension library for common jar files.  The ext is safe
						- even for non-classloader aware jars.  The loaded classes
						- will be loaded separately for each web-app, i.e. the class
						- itself will be distinct.
					  -->
			<!--<class-loader>
				<library-loader path="/usr/local/resin/ext-webapp"/>
			</class-loader>-->

			<!--
						- Sets timeout values for cacheable pages, e.g. static pages.
					  -->
			<!--<cache-mapping url-pattern="/" expires="5s"/>-->
			<cache-mapping url-pattern="*.gif" expires="60s"/>
			<cache-mapping url-pattern="*.jpg" expires="60s"/>
			<cache-mapping url-pattern="*.png" expires="60s"/>

			<!--
						- Enable EL expressions in Servlet and Filter init-param
					  -->
			<allow-servlet-el/>

			<!--
						- for security, disable session URLs by default.
					  -->
			<session-config>
				<enable-url-rewriting>false</enable-url-rewriting>
				<use-persistent-store/>
				<!--<always-save-session/>-->
			</session-config>

			<!--
						- For security, set the HttpOnly flag in cookies.
						- <cookie-http-only/>
					  -->
		</web-app-default>

		<!-- configures a deployment directory for virtual hosts -->
		<host-deploy path="/var/www/hosts">
			<host-default>
				<document-directory>/var/www/hosts/${name}</document-directory>

				<!-- todo: maybe move the cluster-ref to web-app-default -->
				<web-app-deploy path="/var/www/hosts/${name}/webapps">
				</web-app-deploy>

				<!-- This needs to go here instead of web-app-default for some reason. Might be a resin bug. -->
				<class-loader>
					<tree-loader path="${server.root}/ext-webapp"/>
				</class-loader>

			</host-default>
		</host-deploy>

		<!-- configures the default host, matching any host name -->
		<host id="">
			<web-app id="/" root-directory="webapps/ROOT"/>

			<!--
				  - Administration application /resin-admin
				  -
				  - password is the md5 hash of the password.
				  - localhost is true to limit access to the localhost
				 -->
			<!--<web-app id="/resin-admin" root-directory="${resin.home}/php/admin">
				<prologue>
					<resin:set var="resin_admin_password" value=""/>
					<resin:set var="resin_admin_localhost" value="true"/>
				</prologue>
			</web-app>-->
		</host>
	</cluster>
</resin>

