Skip to content

Commit 616503e

Browse files
committed
Fixes to startup scripts, especially for Windows...
1 parent a5e9af8 commit 616503e

File tree

8 files changed

+114
-64
lines changed

8 files changed

+114
-64
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
**/TODO*
12
**/archive/
23
**/bin/
34
**/lib/

crush/Documentation/change.log

+14
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,18 @@
11

2+
3+
[BUG] {Windows} The Windows 'autoconf.bat' had malformed 'if'
4+
conditions causing all CRUSH programs to fail. Fixed.
5+
6+
[BUG] {Windows} Self-extracting .EXE archive was badly broken. It
7+
neither contained the self-extraction code, not the AUTORUN directive.
8+
Both have been fixed.
9+
10+
[TWEAK] A few checks and initialization steps migrated from from
11+
CRUSH.main() to the constructor. This should make it easier to invoke
12+
CRUSH from another Java program...
13+
14+
15+
216
2.42-1 (12 Oct 2018)
317

418

crush/Install/windows/README.windows.txt

-1
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,6 @@ differs from the usual POSIX one. For further details, please look at the __Java
189189
A typical runtime configuration file may contain entries like:
190190

191191
set JAVA=C:\Program Files\Java\jre6\bin\java
192-
set DATAMODEL=64
193192
set USEMB=4000
194193
set JVM=-server
195194
set EXTRAOPTS=-showversion

crush/Install/windows/startup/autoconf.bat

+6-9
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
:: have the desired effect.
88
::
99
:: Author: Attila Kovacs <[email protected]>
10-
:: Date: 12 May 2018
10+
:: Date: 3 November 2018
1111
:: ============================================================================
1212

1313
@echo off
@@ -37,18 +37,15 @@ if errorlevel 1 exit /b 0
3737
set vmtype=
3838
for /f "tokens=* skip=2 USEBACKQ" %%l in (`%JAVA% -version 2^>^&1`) do if not defined vmtype set vmtype=%%l
3939

40-
echo.%vmtype% | FIND /I "64-bit" >Nul
41-
if %errorlevel%!=0 (
42-
echo.%vmtype% | FIND /I "-64" >Nul
43-
if %errorlevel%!=0 (
44-
rem The Windows 32-bit VM seems to max out at around 1200M heap size...
45-
if %USEMB% gtr 1000 set USEMB=1000
46-
)
40+
echo.%vmtype% | FIND /I "64" >Nul
41+
if %errorlevel% neq 0 (
42+
rem The Windows 32-bit VM seems to max out at around 1200M heap size...
43+
if %USEMB% gtr 1000 set USEMB=1000
4744
)
4845

4946

5047
echo.%vmtype% | FIND /I "Server VM" > Nul
51-
if %errorlevel%==0 (
48+
if %errorlevel% eq 0 (
5249
set JVM=-server
5350
)
5451

crush/Install/windows/startup/wrapper.bat

+7-12
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
:: ===========================================================================
22
:: Description: Java configuration wrapper batch file for CRUSH tools.
33
:: Author: Attila Kovacs <[email protected]>
4-
:: Updated: 11 February 2017
4+
:: Updated: 3 November 2018
55
:: ===========================================================================
66
@echo off
77

@@ -22,14 +22,13 @@ call "%STARTUP%\autoconf.bat"
2222
:: You may place entries like:
2323
::
2424
:: set JAVA=C:\Program Files\Java\jre6\bin\java
25-
:: set DATAMODEL=64
26-
:: set USEMB=4000
25+
:: set USEMB=1000
2726
:: set EXTRAOPTS=
2827
::
2928
:: (The contents of which are parsed as a DOS batch file, so you may put other
3029
:: batch directives in there also.). The above would define a user runtime
31-
:: configuration that uses the latest Oracle java in 64-bit mode, allowing to
32-
:: use up to 4GB of ram, with no extra options.
30+
:: configuration that uses the latest Oracle java, allowing to use up to 1GB
31+
:: of ram, with no extra options.
3332
::
3433
:: Add your specific installation defaults below...
3534
:: -----------------------------------------------------------------------------
@@ -40,17 +39,13 @@ call "%STARTUP%\autoconf.bat"
4039
::
4140
::set JAVA=java
4241

43-
:: Set the data model to be 32-bit or 64-bit. To use 64-bit model, you need
44-
:: a 64-bit OS and a 64-bit Java installation
45-
::
46-
::set DATAMODEL=32
47-
4842
:: Choose the maximum amount of RAM (in MB) that you will allow Java to use.
4943
:: The default is to use up to 80% of the total available RAM. On 32-bit
5044
:: machines (or when DATAMODEL is set to "32") the value should remain
51-
:: significantly below 2000, e.g. 1900. In 64-bit mode, you can specify more
45+
:: significantly below 2000, and in practice below 1200. In 64-bit mode, you
46+
:: can specify more...
5247
::
53-
::set USEMB=1900
48+
::set USEMB=1200
5449

5550

5651
:: --------------------- DO NOT CHANGE BELOW THIS LINE -----------------------

crush/src/crush/CRUSH.java

+84-40
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@ public class CRUSH extends Configurator implements BasicMessaging {
6060
*/
6161
private static final long serialVersionUID = 6284421525275783456L;
6262

63-
private static String version = "2.42-1";
64-
private static String revision = "";
63+
private static String version = "2.42-2";
64+
private static String revision = "devel.2";
6565

6666
public static String workPath = ".";
6767
public static String home = ".";
@@ -84,26 +84,8 @@ public class CRUSH extends Configurator implements BasicMessaging {
8484
private int configDepth = 0; // Used for 'nested' output of invoked configurations.
8585

8686

87-
public static void main(String[] args) {
88-
info();
89-
90-
Util.setReporter(broadcaster);
91-
92-
if(args.length == 0) {
93-
usage();
94-
new CRUSH().checkJavaVM(0);
95-
System.exit(0);
96-
}
97-
98-
if(args[0].equalsIgnoreCase("-help")) {
99-
help(null);
100-
System.exit(0);
101-
}
102-
103-
home = System.getenv("CRUSH");
104-
if(home == null) home = ".";
105-
106-
CRUSH crush = new CRUSH(args[0]);
87+
public static void main(String[] args) {
88+
CRUSH crush = new CRUSH();
10789

10890
crush.checkJavaVM(5);
10991
crush.checkForUpdates();
@@ -114,19 +96,78 @@ public static void main(String[] args) {
11496
}
11597
catch(Exception e) { crush.error(e); }
11698

99+
crush.shutdown();
100+
117101
// TODO should not be needed if background processes are all wrapped up...
118-
crush.exit(0);
102+
System.exit(0);
119103
}
120104

121-
private CRUSH() {
105+
public CRUSH() {
106+
info();
107+
122108
Locale.setDefault(Locale.US);
123109
FitsFactory.setUseHierarch(true);
124110
FitsFactory.setLongStringsEnabled(true);
111+
112+
Util.setReporter(broadcaster);
113+
114+
home = System.getenv("CRUSH");
115+
if(home == null) home = ".";
116+
}
117+
118+
/**
119+
* Initialize CRUSH for the given instrument, and no extra options...
120+
*
121+
* @param instrumentName The instrument to use CRUSH with, e.g. "sharc2", or "hirmes"
122+
* @throws Exception If CRUSH could not be initialized with the specified instrument name.
123+
*/
124+
public final void init(String instrumentName) throws Exception {
125+
init(new String[] { instrumentName });
125126
}
127+
128+
/**
129+
* Same as {@link init(String[])} except the arguments as specified as a List rather than
130+
* an array.
131+
* @see init(String[])
132+
*
133+
* @param args A list of arguments, like on the command-line. See {@link init(String[]) for
134+
* more.
135+
* @throws Exception An exception indicative of a problem encountered during initialization.
136+
*/
137+
public final void init(List<String> args) throws Exception {
138+
String[] array = new String[args.size()];
139+
args.toArray(array);
140+
init(array);
141+
}
142+
143+
144+
/**
145+
* Initialize CRUSH for the given argument list, as if the list were command-line arguments.
146+
*
147+
*
148+
* @param args The list of argument to initialize CRUSH with. The first argument must be the
149+
* instrument name to use CRUSH with, e.g. "sharc2" or "hirmes", or else "-help"
150+
* to print just a help screen. The arguments that follow must either be options,
151+
* starting with a dash ('-'), or else scan specifiers. E.g.
152+
*
153+
* { "hirmes", "-faint", "-flight=405", "68", "70-77" }
154+
*
155+
* @throws Exception An exception indicative of a problem encountered during initialization.
156+
*/
157+
public void init(String[] args) throws Exception {
126158

127-
public CRUSH(String instrumentName) {
128-
this();
159+
if(args.length == 0) {
160+
usage();
161+
System.exit(0);
162+
}
129163

164+
if(args[0].equalsIgnoreCase("-help")) {
165+
help(null);
166+
System.exit(0);
167+
}
168+
169+
String instrumentName = args[0];
170+
130171
instrument = Instrument.forName(instrumentName.toLowerCase());
131172
instrument.setOptions(this);
132173

@@ -135,16 +176,8 @@ public CRUSH(String instrumentName) {
135176
System.exit(1);
136177
}
137178

138-
info(this, "Instrument is " + instrument.getName().toUpperCase());
139-
}
140-
141-
public boolean hasOption(String name) {
142-
return isConfigured(name);
143-
}
144-
145-
public Configurator option(String name) { return get(name); }
146-
147-
public void init(String[] args)throws Exception {
179+
info(this, "Instrument is " + instrument.getName().toUpperCase());
180+
148181
readConfig("default.cfg");
149182

150183
this.args = args;
@@ -153,6 +186,14 @@ public void init(String[] args)throws Exception {
153186
validate();
154187
}
155188

189+
public boolean hasOption(String name) {
190+
return isConfigured(name);
191+
}
192+
193+
public Configurator option(String name) { return get(name); }
194+
195+
196+
156197
private void parseArgument(String arg) {
157198
if(arg.charAt(0) == '-') parseSilent(arg.substring(1));
158199
else read(arg);
@@ -1003,10 +1044,13 @@ public void editHeader(Header header) throws HeaderCardException {
10031044
c.add(new HeaderCard("COMMENT", " ----------------------------------------------------", false));
10041045
}
10051046

1006-
1007-
public void exit(int exitValue) {
1047+
public void shutdown() {
10081048
if(instrument != null) instrument.shutdown();
10091049
Util.setDefaultReporter();
1050+
}
1051+
1052+
public void exit(int exitValue) {
1053+
shutdown();
10101054
System.exit(exitValue);
10111055
}
10121056

@@ -1123,9 +1167,9 @@ public final void process(int threads, ExecutorService executor) {
11231167
public static void remove(Reporter r) { broadcaster.remove(r); }
11241168

11251169
public static void removeReporter(String id) { broadcaster.remove(id); }
1170+
11261171

1127-
1128-
1172+
11291173
public static CRUSHConsoleReporter consoleReporter = new CRUSHConsoleReporter("crush-console");
11301174
public static Broadcaster broadcaster = new Broadcaster("CRUSH-broadcast", consoleReporter);
11311175

crush/startup/autoconf.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
# the desired effect.
1313
#
1414
# Author: Attila Kovacs <[email protected]>
15-
# Date: 12 May 2018
15+
# Date: 3 November 2018
1616
# ============================================================================
1717

1818
# Start by fail-safe defaults: default java, 32-bit mode, 1 GB of RAM, and

crush/startup/wrapper.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# ===========================================================================
44
# Description: Java configuration wrapper script for CRUSH tools.
55
# Author: Attila Kovacs <[email protected]>
6-
# Updated: 12 May 2018
6+
# Updated: 3 November 2018
77
# ===========================================================================
88

99
# Attempt to auto configure CRUSH. This should provide optimal settings on

0 commit comments

Comments
 (0)