support to boot on the windows

This commit is contained in:
Kaoru FUZITA 2015-12-11 18:15:22 +09:00
parent 3dd6683deb
commit a94c9784a7
11 changed files with 451 additions and 27 deletions

38
pom.xml
View file

@ -94,6 +94,13 @@
<directory>src/main/resources</directory>
</resource>
</resources>
<!-- This file contains all the common properties used to build the different
packages (tar.gz, deb, rpm) using Maven resources plugin -->
<filters>
<filter>src/packaging/common/packaging.properties</filter>
</filters>
<pluginManagement>
<plugins>
<plugin>
@ -284,6 +291,32 @@
<artifactId>maven-resources-plugin</artifactId>
<version>2.6</version>
<executions>
<execution>
<id>copy-resources</id>
<phase>prepare-package</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/bin</outputDirectory>
<resources>
<resource>
<directory>${basedir}/bin</directory>
<filtering>true</filtering>
<excludes>
<exclude>*.exe</exclude>
</excludes>
</resource>
<resource>
<directory>${basedir}/bin</directory>
<filtering>false</filtering>
<includes>
<include>*.exe</include>
</includes>
</resource>
</resources>
</configuration>
</execution>
<execution>
<id>copy-resources-rpm</id>
<phase>prepare-package</phase>
@ -331,7 +364,7 @@
</executions>
</plugin>
<!-- zip -->
<!-- zip, tarball -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
@ -341,7 +374,8 @@
<appendAssemblyId>false</appendAssemblyId>
<outputDirectory>${project.build.directory}/releases/</outputDirectory>
<descriptors>
<descriptor>${basedir}/src/main/assemblies/package.xml</descriptor>
<descriptor>${basedir}/src/main/assemblies/targz-bin.xml</descriptor>
<descriptor>${basedir}/src/main/assemblies/zip-bin.xml</descriptor>
</descriptors>
</configuration>
<executions>

View file

@ -1,16 +1,7 @@
<?xml version="1.0"?>
<assembly
xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.3"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.3 http://maven.apache.org/xsd/assembly-1.1.3.xsd">
<id>package</id>
<formats>
<format>zip</format>
</formats>
<includeBaseDirectory>false</includeBaseDirectory>
<component>
<dependencySets>
<dependencySet>
<outputDirectory>fess-${project.version}/app</outputDirectory>
<outputDirectory>/app</outputDirectory>
<useProjectArtifact>true</useProjectArtifact>
<unpack>true</unpack>
<includes>
@ -19,25 +10,49 @@
</dependencySet>
</dependencySets>
<fileSets>
<!-- LICENSE -->
<fileSet>
<directory>${project.basedir}</directory>
<filtered>true</filtered>
<directory>src/main/assemblies/files</directory>
<outputDirectory>bin</outputDirectory>
<lineEnding>dos</lineEnding>
<includes>
<include>LICENSE</include>
<include>fess.in.bat</include>
<include>fess.bat</include>
<include>service.bat</include>
</includes>
<outputDirectory>fess-${project.version}</outputDirectory>
</fileSet>
<fileSet>
<filtered>false</filtered>
<directory>src/main/assemblies/files</directory>
<outputDirectory>bin</outputDirectory>
<includes>
<include>*.exe</include>
</includes>
</fileSet>
<fileSet>
<filtered>true</filtered>
<directory>src/main/assemblies/files</directory>
<outputDirectory>bin</outputDirectory>
<fileMode>0755</fileMode>
<directoryMode>0755</directoryMode>
<lineEnding>unix</lineEnding>
<includes>
<include>fess.in.sh</include>
<include>fess</include>
</includes>
</fileSet>
<!-- lib -->
<fileSet>
<directory>${project.build.directory}/tomcat-lib</directory>
<outputDirectory>fess-${project.version}/lib/classes</outputDirectory>
<outputDirectory>/lib/classes</outputDirectory>
</fileSet>
<fileSet>
<directory>${project.build.directory}/fess/WEB-INF/classes/org/codelibs/fess/</directory>
<includes>
<include>FessBoot**</include>
</includes>
<outputDirectory>fess-${project.version}/lib/classes/org/codelibs/fess</outputDirectory>
<outputDirectory>/lib/classes/org/codelibs/fess</outputDirectory>
</fileSet>
<fileSet>
<directory>${project.basedir}/src/main/assemblies/files</directory>
@ -45,9 +60,10 @@
<include>logging.properties</include>
<include>tomcat_config.properties</include>
</includes>
<outputDirectory>fess-${project.version}/lib/classes</outputDirectory>
<outputDirectory>/lib/classes</outputDirectory>
</fileSet>
<!-- app -->
<!--
<fileSet>
<directory>${project.basedir}/src/main/assemblies/files</directory>
<fileMode>0755</fileMode>
@ -56,12 +72,13 @@
<include>fess</include>
<include>fess.in.sh</include>
</includes>
<outputDirectory>fess-${project.version}/bin</outputDirectory>
<outputDirectory>/bin</outputDirectory>
</fileSet>
-->
<!-- logs -->
<fileSet>
<directory>src/main/assemblies/files</directory>
<outputDirectory>fess-${project.version}/logs</outputDirectory>
<outputDirectory>/logs</outputDirectory>
<excludes>
<exclude>*</exclude>
</excludes>
@ -70,7 +87,7 @@
<!-- temp -->
<fileSet>
<directory>src/main/assemblies/files</directory>
<outputDirectory>fess-${project.version}/temp</outputDirectory>
<outputDirectory>/temp</outputDirectory>
<excludes>
<exclude>*</exclude>
</excludes>
@ -79,16 +96,26 @@
<!-- es/plugins -->
<fileSet>
<directory>${project.basedir}/plugins</directory>
<outputDirectory>fess-${project.version}/es/plugins</outputDirectory>
<outputDirectory>/es/plugins</outputDirectory>
</fileSet>
<!-- es/data -->
<fileSet>
<directory>src/main/assemblies/files</directory>
<outputDirectory>fess-${project.version}/es/data</outputDirectory>
<outputDirectory>/es/data</outputDirectory>
<excludes>
<exclude>*</exclude>
</excludes>
<filtered>false</filtered>
</fileSet>
</fileSets>
</assembly>
<files>
<file>
<source>README.md</source>
<outputDirectory>/</outputDirectory>
</file>
<file>
<source>LICENSE</source>
<outputDirectory>/</outputDirectory>
</file>
</files>
</component>

Binary file not shown.

Binary file not shown.

View file

@ -0,0 +1,59 @@
@echo off
SETLOCAL enabledelayedexpansion
TITLE Fess 10.0.0-SNAPSHOT
SET params='%*'
:loop
FOR /F "usebackq tokens=1* delims= " %%A IN (!params!) DO (
SET current=%%A
SET params='%%B'
SET silent=N
IF "!current!" == "-s" (
SET silent=Y
)
IF "!current!" == "--silent" (
SET silent=Y
)
IF "!silent!" == "Y" (
SET nopauseonerror=Y
) ELSE (
IF "x!newparams!" NEQ "x" (
SET newparams=!newparams! !current!
) ELSE (
SET newparams=!current!
)
)
IF "x!params!" NEQ "x" (
GOTO loop
)
)
SET HOSTNAME=%COMPUTERNAME%
CALL "%~dp0fess.in.bat"
IF ERRORLEVEL 1 (
IF NOT DEFINED nopauseonerror (
PAUSE
)
EXIT /B %ERRORLEVEL%
)
set FESS_JAVA_OPTS=%FESS_JAVA_OPTS% -Dfess.home=%FESS_HOME%
set FESS_JAVA_OPTS=%FESS_JAVA_OPTS% -Dfess.context.path=%APP_NAME%
set FESS_JAVA_OPTS=%FESS_JAVA_OPTS% -Dfess.port=8080
set FESS_JAVA_OPTS=%FESS_JAVA_OPTS% -Dfess.webapp.path=%FESS_HOME%\app
set FESS_JAVA_OPTS=%FESS_JAVA_OPTS% -Dfess.temp.path=%FESS_HOME%\temp
set FESS_JAVA_OPTS=%FESS_JAVA_OPTS% -Dfess.log.name=%APP_NAME%
set FESS_JAVA_OPTS=%FESS_JAVA_OPTS% -Dfess.log.path=%FESS_HOME%\logs
set FESS_JAVA_OPTS=%FESS_JAVA_OPTS% -Dfess.log.level=warn
set FESS_JAVA_OPTS=%FESS_JAVA_OPTS% -Dlasta.env=production
set FESS_JAVA_OPTS=%FESS_JAVA_OPTS% -Dtomcat.config.path=tomcat_config.properties
"%JAVA_HOME%\bin\java" %JAVA_OPTS% %FESS_JAVA_OPTS% %FESS_PARAMS% !newparams! -cp "%FESS_CLASSPATH%" "org.codelibs.fess.FessBoot"
ENDLOCAL

View file

@ -0,0 +1,87 @@
@echo off
if DEFINED JAVA_HOME goto cont
:err
ECHO JAVA_HOME environment variable must be set! 1>&2
EXIT /B 1
:cont
set SCRIPT_DIR=%~dp0
for %%I in ("%SCRIPT_DIR%..") do set FESS_HOME=%%~dpfI
REM ***** JAVA options *****
if "%FESS_MIN_MEM%" == "" (
set FESS_MIN_MEM=256m
)
if "%FESS_MAX_MEM%" == "" (
set FESS_MAX_MEM=1g
)
if NOT "%FESS_HEAP_SIZE%" == "" (
set FESS_MIN_MEM=%FESS_HEAP_SIZE%
set FESS_MAX_MEM=%FESS_HEAP_SIZE%
)
REM min and max heap sizes should be set to the same value to avoid
REM stop-the-world GC pauses during resize, and so that we can lock the
REM heap in memory on startup to prevent any of it from being swapped
REM out.
set JAVA_OPTS=%JAVA_OPTS% -Xms%FESS_MIN_MEM% -Xmx%FESS_MAX_MEM%
REM new generation
if NOT "%FESS_HEAP_NEWSIZE%" == "" (
set JAVA_OPTS=%JAVA_OPTS% -Xmn%FESS_HEAP_NEWSIZE%
)
REM max direct memory
if NOT "%FESS_DIRECT_SIZE%" == "" (
set JAVA_OPTS=%JAVA_OPTS% -XX:MaxDirectMemorySize=%FESS_DIRECT_SIZE%
)
REM set to headless, just in case
set JAVA_OPTS=%JAVA_OPTS% -Djava.awt.headless=true
REM Force the JVM to use IPv4 stack
if NOT "%FESS_USE_IPV4%" == "" (
set JAVA_OPTS=%JAVA_OPTS% -Djava.net.preferIPv4Stack=true
)
set JAVA_OPTS=%JAVA_OPTS% -XX:+UseParNewGC
set JAVA_OPTS=%JAVA_OPTS% -XX:+UseConcMarkSweepGC
set JAVA_OPTS=%JAVA_OPTS% -XX:CMSInitiatingOccupancyFraction=75
set JAVA_OPTS=%JAVA_OPTS% -XX:+UseCMSInitiatingOccupancyOnly
REM When running under Java 7
REM JAVA_OPTS=%JAVA_OPTS% -XX:+UseCondCardMark
if NOT "%FESS_USE_GC_LOGGING%" == "" set JAVA_OPTS=%JAVA_OPTS% -XX:+PrintGCDetails
if NOT "%FESS_USE_GC_LOGGING%" == "" set JAVA_OPTS=%JAVA_OPTS% -XX:+PrintGCTimeStamps
if NOT "%FESS_USE_GC_LOGGING%" == "" set JAVA_OPTS=%JAVA_OPTS% -XX:+PrintGCDateStamps
if NOT "%FESS_USE_GC_LOGGING%" == "" set JAVA_OPTS=%JAVA_OPTS% -XX:+PrintClassHistogram
if NOT "%FESS_USE_GC_LOGGING%" == "" set JAVA_OPTS=%JAVA_OPTS% -XX:+PrintTenuringDistribution
if NOT "%FESS_USE_GC_LOGGING%" == "" set JAVA_OPTS=%JAVA_OPTS% -XX:+PrintGCApplicationStoppedTime
if NOT "%FESS_USE_GC_LOGGING%" == "" set JAVA_OPTS=%JAVA_OPTS% -Xloggc:%FESS_HOME%/logs/gc.log
REM Causes the JVM to dump its heap on OutOfMemory.
set JAVA_OPTS=%JAVA_OPTS% -XX:+HeapDumpOnOutOfMemoryError
REM The path to the heap dump location, note directory must exists and have enough
REM space for a full heap dump.
REM JAVA_OPTS=%JAVA_OPTS% -XX:HeapDumpPath=%FESS_HOME%/logs/heapdump.hprof
REM Disables explicit GC
set JAVA_OPTS=%JAVA_OPTS% -XX:+DisableExplicitGC
REM Ensure UTF-8 encoding by default (e.g. filenames)
set JAVA_OPTS=%JAVA_OPTS% -Dfile.encoding=UTF-8
REM Application Configuration
set APP_NAME=fess
set ES_HOME=%FESS_HOME%/es
set FESS_CLASSPATH=%FESS_HOME%\lib\classes
set FESS_PARAMS=-Dfess -Des-foreground=yes -Dfess.home="%FESS_HOME%" -Dfess.es.dir="%ES_HOME%"

View file

@ -5,6 +5,6 @@ java.util.logging.ConsoleHandler.level=INFO
java.util.logging.ConsoleHandler.formatter=java.util.logging.SimpleFormatter
java.util.logging.FileHandler.level=INFO
java.util.logging.FileHandler.pattern=${fess.home}/logs/server_%g.log
java.util.logging.FileHandler.pattern=../../logs/server_%g.log
java.util.logging.FileHandler.formatter=java.util.logging.SimpleFormatter
java.util.logging.FileHandler.count=10

View file

@ -0,0 +1,185 @@
@echo off
SETLOCAL
TITLE Fess Service 10.0.0-SNAPSHOT
if NOT DEFINED JAVA_HOME goto err
set SCRIPT_DIR=%~dp0
for %%I in ("%SCRIPT_DIR%..") do set FESS_HOME=%%~dpfI
rem Detect JVM version to figure out appropriate executable to use
if not exist "%JAVA_HOME%\bin\java.exe" (
echo JAVA_HOME points to an invalid Java installation (no java.exe found in "%JAVA_HOME%"^). Exiting...
goto:eof
)
"%JAVA_HOME%\bin\java" -version 2>&1 | "%windir%\System32\find" "64-Bit" >nul:
if errorlevel 1 goto x86
set EXECUTABLE=%FESS_HOME%\bin\fess-service-x64.exe
set SERVICE_ID=fess-service-x64
set ARCH=64-bit
goto checkExe
:x86
set EXECUTABLE=%FESS_HOME%\bin\fess-service-x86.exe
set SERVICE_ID=fess-service-x86
set ARCH=32-bit
:checkExe
if EXIST "%EXECUTABLE%" goto okExe
echo fess-service-(x86|x64).exe was not found...
:okExe
set FESS_VERSION=10.0.0-SNAPSHOT
if "%LOG_DIR%" == "" set LOG_DIR=%FESS_HOME%\logs
if "x%1x" == "xx" goto displayUsage
set SERVICE_CMD=%1
shift
if "x%1x" == "xx" goto checkServiceCmd
set SERVICE_ID=%1
:checkServiceCmd
if "%LOG_OPTS%" == "" set LOG_OPTS=--LogPath "%LOG_DIR%" --LogPrefix "%SERVICE_ID%" --StdError auto --StdOutput auto
if /i %SERVICE_CMD% == install goto doInstall
if /i %SERVICE_CMD% == remove goto doRemove
if /i %SERVICE_CMD% == start goto doStart
if /i %SERVICE_CMD% == stop goto doStop
if /i %SERVICE_CMD% == manager goto doManagment
echo Unknown option "%SERVICE_CMD%"
:displayUsage
echo.
echo Usage: service.bat install^|remove^|start^|stop^|manager [SERVICE_ID]
goto:eof
:doStart
"%EXECUTABLE%" //ES//%SERVICE_ID% %LOG_OPTS%
if not errorlevel 1 goto started
echo Failed starting '%SERVICE_ID%' service
goto:eof
:started
echo The service '%SERVICE_ID%' has been started
goto:eof
:doStop
"%EXECUTABLE%" //SS//%SERVICE_ID% %LOG_OPTS%
if not errorlevel 1 goto stopped
echo Failed stopping '%SERVICE_ID%' service
goto:eof
:stopped
echo The service '%SERVICE_ID%' has been stopped
goto:eof
:doRemove
rem Remove the service
"%EXECUTABLE%" //DS//%SERVICE_ID% %LOG_OPTS%
if not errorlevel 1 goto removed
echo Failed removing '%SERVICE_ID%' service
goto:eof
:removed
echo The service '%SERVICE_ID%' has been removed
goto:eof
:doInstall
echo Installing service : "%SERVICE_ID%"
echo Using JAVA_HOME (%ARCH%): "%JAVA_HOME%"
rem Check JVM server dll first
set JVM_DLL=%JAVA_HOME%\jre\bin\server\jvm.dll
if exist "%JVM_DLL%" goto foundJVM
rem Check 'server' JRE (JRE installed on Windows Server)
set JVM_DLL=%JAVA_HOME%\bin\server\jvm.dll
if exist "%JVM_DLL%" goto foundJVM
rem Fallback to 'client' JRE
set JVM_DLL=%JAVA_HOME%\bin\client\jvm.dll
if exist "%JVM_DLL%" (
echo Warning: JAVA_HOME points to a JRE and not JDK installation; a client (not a server^) JVM will be used...
) else (
echo JAVA_HOME points to an invalid Java installation (no jvm.dll found in "%JAVA_HOME%"^). Existing...
goto:eof
)
:foundJVM
if "%FESS_MIN_MEM%" == "" set FESS_MIN_MEM=256m
if "%FESS_MAX_MEM%" == "" set FESS_MAX_MEM=1g
if NOT "%FESS_HEAP_SIZE%" == "" set FESS_MIN_MEM=%FESS_HEAP_SIZE%
if NOT "%FESS_HEAP_SIZE%" == "" set FESS_MAX_MEM=%FESS_HEAP_SIZE%
call:convertxm %FESS_MIN_MEM% JVM_XMS
call:convertxm %FESS_MAX_MEM% JVM_XMX
REM java_opts might be empty - init to avoid tripping commons daemon (if the command starts with ;)
if "%JAVA_OPTS%" == "" set JAVA_OPTS=-XX:+UseParNewGC
CALL "%FESS_HOME%\bin\fess.in.bat"
rem thread stack size
set JVM_SS=256
set FESS_PARAMS=-Dfess;-Dfess.home="%FESS_HOME%";-Dfess.es.dir="%ES_HOME%";-Dfess.home="%FESS_HOME%";-Dfess.context.path="%APP_NAME%";-Dfess.port=8080;-Dfess.webapp.path="%FESS_HOME%\app";-Dfess.temp.path="%FESS_HOME%\temp";-Dfess.log.name="%APP_NAME%";-Dfess.log.path="%FESS_HOME%\logs";-Dfess.log.level=warn;-Dlasta.env=production;-Dtomcat.config.path=tomcat_config.properties
set JVM_OPTS=%JAVA_OPTS: =;%
if not "%FESS_JAVA_OPTS%" == "" set JVM_FESS_JAVA_OPTS=%FESS_JAVA_OPTS: =#%
if not "%FESS_JAVA_OPTS%" == "" set JVM_OPTS=%JVM_OPTS%;%JVM_FESS_JAVA_OPTS%
if "%FESS_START_TYPE%" == "" set FESS_START_TYPE=manual
if "%FESS_STOP_TIMEOUT%" == "" set FESS_STOP_TIMEOUT=0
"%EXECUTABLE%" //IS//%SERVICE_ID% --Startup %FESS_START_TYPE% --StopTimeout %FESS_STOP_TIMEOUT% --StartClass org.codelibs.fess.FessBoot --StopClass org.codelibs.fess.FessBoot --StartMethod main --StopMethod shutdown --Classpath "%FESS_CLASSPATH%" --JvmSs %JVM_SS% --JvmMs %JVM_XMS% --JvmMx %JVM_XMX% --JvmOptions %JVM_OPTS% ++JvmOptions %FESS_PARAMS% %LOG_OPTS% --PidFile "%SERVICE_ID%.pid" --DisplayName "Fess %FESS_VERSION% (%SERVICE_ID%)" --Description "Fess %FESS_VERSION% Windows Service - https://github.com/codelibs/fess" --Jvm "%JVM_DLL%" --StartMode jvm --StopMode jvm --StartPath "%FESS_HOME%"
if not errorlevel 1 goto installed
echo Failed installing '%SERVICE_ID%' service
goto:eof
:installed
echo The service '%SERVICE_ID%' has been installed.
goto:eof
:err
echo JAVA_HOME environment variable must be set!
pause
goto:eof
rem ---
rem Function for converting Xm[s|x] values into MB which Commons Daemon accepts
rem ---
:convertxm
set value=%~1
rem extract last char (unit)
set unit=%value:~-1%
rem assume the unit is specified
set conv=%value:~0,-1%
if "%unit%" == "k" goto kilo
if "%unit%" == "K" goto kilo
if "%unit%" == "m" goto mega
if "%unit%" == "M" goto mega
if "%unit%" == "g" goto giga
if "%unit%" == "G" goto giga
rem no unit found, must be bytes; consider the whole value
set conv=%value%
rem convert to KB
set /a conv=%conv% / 1024
:kilo
rem convert to MB
set /a conv=%conv% / 1024
goto mega
:giga
rem convert to MB
set /a conv=%conv% * 1024
:mega
set "%~2=%conv%"
goto:eof
ENDLOCAL

View file

@ -0,0 +1,14 @@
<?xml version="1.0"?>
<assembly>
<id>targz</id>
<formats>
<format>tar.gz</format>
</formats>
<includeBaseDirectory>true</includeBaseDirectory>
<componentDescriptors>
<componentDescriptor>src/main/assemblies/common-bin.xml
</componentDescriptor>
</componentDescriptors>
</assembly>

View file

@ -0,0 +1,14 @@
<?xml version="1.0"?>
<assembly>
<id>zip</id>
<formats>
<format>zip</format>
</formats>
<includeBaseDirectory>true</includeBaseDirectory>
<componentDescriptors>
<componentDescriptor>src/main/assemblies/common-bin.xml
</componentDescriptor>
</componentDescriptors>
</assembly>

View file

@ -80,6 +80,10 @@ public class FessBoot extends TomcatBoot {
.asDevelopment(isNoneEnv()).bootAwait();
}
public static void shutdown(String[] args) {
System.exit(0);
}
private static boolean isNoneEnv() {
return System.getProperty("lasta.env") == null;
}