forked from vufind-org/vufind
-
Notifications
You must be signed in to change notification settings - Fork 0
/
run_vufind.bat
175 lines (151 loc) · 5.1 KB
/
run_vufind.bat
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
@echo off
rem Startup script for the VuFind Jetty Server under Windows
rem
rem Configuration variables
rem
rem VUFIND_HOME
rem Home of the VuFind installation.
rem
rem SOLR_HOME
rem Home of the Solr installation.
rem
rem JAVA_HOME
rem Home of Java installation.
rem
rem JAVA
rem Command to invoke Java. If not set, %JAVA_HOME%\bin\java will be
rem used.
rem
rem JAVA_OPTIONS
rem Extra options to pass to the JVM
rem
rem JETTY_HOME
rem Where Jetty is installed. If not set, the script will try to guess it based
rem on the SOLR_HOME setting. The java system property "jetty.home" will be
rem set to this value for use by configure.xml files, f.e.:
rem
rem <Arg><SystemProperty name="jetty.home" default="."/>\webapps\jetty.war</Arg>
rem
rem JETTY_LOG
rem The path where Jetty will store the log files
rem
rem JETTY_PORT
rem Override the default port for Jetty servers. If not set then the
rem default value in the xml configuration file will be used. The java
rem system property "jetty.port" will be set to this value for use in
rem configure.xml files. For example, the following idiom is widely
rem used in the demo config files to respect this property in Listener
rem configuration elements:
rem
rem <Set name="Port"><SystemProperty name="jetty.port" default="8080"/></Set>
rem
rem Note: that the config file could ignore this property simply by saying:
rem
rem <Set name="Port">8080</Set>
rem
rem JETTY_ARGS
rem The default arguments to pass to jetty.
rem Make sure that environment edits are local and that we have access to the
rem Windows command extensions.
setlocal enableextensions
if not errorlevel 1 goto extensionsokay
echo Unable to enable Windows command extensions.
goto end
:extensionsokay
rem Get the action and shift the parameter list (in case we implement configuration
rem files in the future)
set ACTION=%1
shift
rem Set Performance options for JETTY
if not "!%JAVA_OPTIONS%!"=="!!" goto javaoptionsset
set JAVA_OPTIONS=-server -Xms1024m -Xmx1024m -XX:+UseParallelGC -XX:NewRatio=5
:javaoptionsset
rem Set VUFIND_HOME (if not already set)
if not "!%VUFIND_HOME%!"=="!!" goto vufindhomeset
set VUFIND_HOME=c:\vufind
:vufindhomeset
rem Set SOLR_HOME
if not "!%SOLR_HOME%!"=="!!" goto solrhomeset
set SOLR_HOME=%VUFIND_HOME%\solr
:solrhomeset
rem Set JETTY_HOME
if not "!%JETTY_HOME%!"=="!!" goto jettyhomeset
set JETTY_HOME=%SOLR_HOME%\jetty
:jettyhomeset
rem Set Jetty's Logging Directory
if not "!%JETTY_LOG%!"=="!!" goto jettylogset
set JETTY_LOG=%JETTY_HOME%\logs
:jettylogset
rem Jetty's hallmark
set JETTY_INSTALL_TRACE_FILE=start.jar
rem Check that jetty is where we think it is
if exist "%JETTY_HOME%\%JETTY_INSTALL_TRACE_FILE%" goto jettyokay
echo ** ERROR: Oops! Jetty doesn't appear to be installed in %JETTY_HOME%
echo ** ERROR: %JETTY_HOME%\%JETTY_INSTALL_TRACE_FILE% is not readable!
goto end
:jettyokay
rem Advanced configuration files not currently supported -- just run standard server
set CONFIGS=%JETTY_HOME%\etc\jetty.xml
rem Take a stab at detecting JAVA_HOME before we die
if not "!%JAVA_HOME%!"=="!!" goto javahomeokay
echo Detecting Java...
set KeyName=HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Development Kit
set Cmd=reg query "%KeyName%" /s
for /f "tokens=2*" %%i in ('%Cmd% ^| findstr "JavaHome"') do set JAVA_HOME=%%j
rem Make sure JAVA_HOME is set
if not "!%JAVA_HOME%!"=="!!" goto javahomeokay
echo ** ERROR: The JAVA_HOME environment variable must be set.
goto end
:javahomeokay
rem Choose default Java command if it was not set externally:
if not "!%JAVA%!"=="!!" goto javaset
set JAVA=%JAVA_HOME%\bin\java
:javaset
rem See if JETTY_PORT is defined
if "!%JETTY_PORT%!"=="!!" goto skipjettyport
set JAVA_OPTIONS=%JAVA_OPTIONS% -Djetty.port=%JETTY_PORT%
:skipjettyport
rem Add Solr values to command line
if "!%SOLR_HOME%!"=="!!" goto skipsolrhome
set JAVA_OPTIONS=%JAVA_OPTIONS% -Dsolr.solr.home=%SOLR_HOME%
:skipsolrhome
rem Set Jetty Logging Directory
if "!%JETTY_LOG%!"=="!!" goto skipjettylog
set JAVA_OPTIONS=%JAVA_OPTIONS% -Djetty.logs=%JETTY_LOG%
:skipjettylog
rem Add jetty properties to Java VM options.
set JAVA_OPTIONS=%JAVA_OPTIONS% -Djetty.home=%JETTY_HOME%
rem This is how the Jetty server will be started
set RUN_CMD="%JAVA%" %JAVA_OPTIONS% -jar %JETTY_HOME%\%JETTY_INSTALL_TRACE_FILE% %JETTY_ARGS% %CONFIGS%
rem Perform the requested action
if %ACTION%!==start! goto startvufind
if %ACTION%!==check! goto checkvufind
rem Unrecognized action -- display help text
goto usage
rem Logic for "start" action:
:startvufind
echo Running command: %RUN_CMD%
%RUN_CMD%
goto end
rem Logic for "check" action:
:checkvufind
echo Checking arguments to VuFind:
echo VUFIND_HOME = %VUFIND_HOME%
echo SOLR_HOME = %SOLR_HOME%
echo JETTY_HOME = %JETTY_HOME%
echo JETTY_LOG = %JETTY_LOG%
echo JETTY_PORT = %JETTY_PORT%
echo CONFIGS = %CONFIGS%
echo JAVA_OPTIONS = %JAVA_OPTIONS%
echo JAVA = %JAVA%
echo RUN_CMD = %RUN_CMD%
echo.
goto usage
:usage
echo Usage: vufind {start / check}
echo.
echo Note: To stop VuFind, open the window where it is running and hit Ctrl-C.
goto end
:end
rem We're all done -- close down the local environment.
endlocal