always shutdown log, fixes zombie processes in init stop script

git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@7780 6c8d7289-2bf4-0310-a012-ef5d649a1542
pull/1/head
f1ori 14 years ago
parent 115abc8917
commit f87865a50b

@ -927,97 +927,102 @@ public final class yacy {
*/ */
public static void main(String args[]) { public static void main(String args[]) {
// check assertion status try {
//ClassLoader.getSystemClassLoader().setDefaultAssertionStatus(true);
boolean assertionenabled = false; // check assertion status
assert assertionenabled = true; //ClassLoader.getSystemClassLoader().setDefaultAssertionStatus(true);
if (assertionenabled) System.out.println("Asserts are enabled"); boolean assertionenabled = false;
assert assertionenabled = true;
// check memory amount if (assertionenabled) System.out.println("Asserts are enabled");
System.gc();
final long startupMemFree = MemoryControl.free(); // check memory amount
final long startupMemTotal = MemoryControl.total(); System.gc();
final long startupMemFree = MemoryControl.free();
// maybe go into headless awt mode: we have three cases depending on OS and one exception: final long startupMemTotal = MemoryControl.total();
// windows : better do not go into headless mode
// mac : go into headless mode because an application is shown in gui which may not be wanted // maybe go into headless awt mode: we have three cases depending on OS and one exception:
// linux : go into headless mode because this does not need any head operation // windows : better do not go into headless mode
// exception : if the -gui option is used then do not go into headless mode since that uses a gui // mac : go into headless mode because an application is shown in gui which may not be wanted
boolean headless = true; // linux : go into headless mode because this does not need any head operation
if (OS.isWindows) headless = false; // exception : if the -gui option is used then do not go into headless mode since that uses a gui
if (args.length >= 1 && args[0].toLowerCase().equals("-gui")) headless = false; boolean headless = true;
System.setProperty("java.awt.headless", headless ? "true" : "false"); if (OS.isWindows) headless = false;
if (args.length >= 1 && args[0].toLowerCase().equals("-gui")) headless = false;
String s = ""; for (String a: args) s += a + " "; System.setProperty("java.awt.headless", headless ? "true" : "false");
yacyRelease.startParameter = s.trim();
String s = ""; for (String a: args) s += a + " ";
File applicationRoot = new File(System.getProperty("user.dir").replace('\\', '/')); yacyRelease.startParameter = s.trim();
File dataRoot = applicationRoot;
//System.out.println("args.length=" + args.length); File applicationRoot = new File(System.getProperty("user.dir").replace('\\', '/'));
//System.out.print("args=["); for (int i = 0; i < args.length; i++) System.out.print(args[i] + ", "); System.out.println("]"); File dataRoot = applicationRoot;
if ((args.length >= 1) && (args[0].toLowerCase().equals("-startup") || args[0].equals("-start"))) { //System.out.println("args.length=" + args.length);
// normal start-up of yacy //System.out.print("args=["); for (int i = 0; i < args.length; i++) System.out.print(args[i] + ", "); System.out.println("]");
if (args.length > 1) dataRoot = new File(System.getProperty("user.home").replace('\\', '/'), args[1]); if ((args.length >= 1) && (args[0].toLowerCase().equals("-startup") || args[0].equals("-start"))) {
startup(dataRoot, applicationRoot, startupMemFree, startupMemTotal, false); // normal start-up of yacy
} else if (args.length >= 1 && args[0].toLowerCase().equals("-gui")) { if (args.length > 1) dataRoot = new File(System.getProperty("user.home").replace('\\', '/'), args[1]);
// start-up of yacy with gui startup(dataRoot, applicationRoot, startupMemFree, startupMemTotal, false);
if (args.length > 1) dataRoot = new File(System.getProperty("user.home").replace('\\', '/'), args[1]); } else if (args.length >= 1 && args[0].toLowerCase().equals("-gui")) {
startup(dataRoot, applicationRoot, startupMemFree, startupMemTotal, true); // start-up of yacy with gui
} else if ((args.length >= 1) && ((args[0].toLowerCase().equals("-shutdown")) || (args[0].equals("-stop")))) { if (args.length > 1) dataRoot = new File(System.getProperty("user.home").replace('\\', '/'), args[1]);
// normal shutdown of yacy startup(dataRoot, applicationRoot, startupMemFree, startupMemTotal, true);
if (args.length == 2) applicationRoot= new File(args[1]); } else if ((args.length >= 1) && ((args[0].toLowerCase().equals("-shutdown")) || (args[0].equals("-stop")))) {
shutdown(applicationRoot); // normal shutdown of yacy
} else if ((args.length >= 1) && (args[0].toLowerCase().equals("-update"))) { if (args.length == 2) applicationRoot= new File(args[1]);
// aut-update yacy shutdown(applicationRoot);
if (args.length == 2) applicationRoot= new File(args[1]); } else if ((args.length >= 1) && (args[0].toLowerCase().equals("-update"))) {
update(applicationRoot); // aut-update yacy
} else if ((args.length >= 1) && (args[0].toLowerCase().equals("-version"))) { if (args.length == 2) applicationRoot= new File(args[1]);
// show yacy version update(applicationRoot);
System.out.println(copyright); } else if ((args.length >= 1) && (args[0].toLowerCase().equals("-version"))) {
} else if ((args.length >= 1) && (args[0].toLowerCase().equals("-minimizeurldb"))) { // show yacy version
// migrate words from DATA/PLASMADB/WORDS path to assortment cache, if possible System.out.println(copyright);
// attention: this may run long and should not be interrupted! } else if ((args.length >= 1) && (args[0].toLowerCase().equals("-minimizeurldb"))) {
if (args.length >= 3 && args[1].toLowerCase().equals("-cache")) { // migrate words from DATA/PLASMADB/WORDS path to assortment cache, if possible
args = shift(args, 1, 2); // attention: this may run long and should not be interrupted!
} if (args.length >= 3 && args[1].toLowerCase().equals("-cache")) {
if (args.length == 2) applicationRoot= new File(args[1]); args = shift(args, 1, 2);
minimizeUrlDB(dataRoot, applicationRoot, "freeworld"); }
} else if ((args.length >= 1) && (args[0].toLowerCase().equals("-testpeerdb"))) { if (args.length == 2) applicationRoot= new File(args[1]);
if (args.length == 2) { minimizeUrlDB(dataRoot, applicationRoot, "freeworld");
applicationRoot = new File(args[1]); } else if ((args.length >= 1) && (args[0].toLowerCase().equals("-testpeerdb"))) {
} else if (args.length > 2) { if (args.length == 2) {
System.err.println("Usage: -testPeerDB [homeDbRoot]"); applicationRoot = new File(args[1]);
} } else if (args.length > 2) {
testPeerDB(applicationRoot); System.err.println("Usage: -testPeerDB [homeDbRoot]");
} else if ((args.length >= 1) && (args[0].toLowerCase().equals("-genwordstat"))) { }
// this can help to create a stop-word list testPeerDB(applicationRoot);
// to use this, you need a 'yacy.words' file in the root path } else if ((args.length >= 1) && (args[0].toLowerCase().equals("-genwordstat"))) {
// start this with "java -classpath classes yacy -genwordstat [<rootdir>]" // this can help to create a stop-word list
if (args.length == 2) applicationRoot= new File(args[1]); // to use this, you need a 'yacy.words' file in the root path
genWordstat(applicationRoot); // start this with "java -classpath classes yacy -genwordstat [<rootdir>]"
} else if ((args.length == 4) && (args[0].toLowerCase().equals("-cleanwordlist"))) { if (args.length == 2) applicationRoot= new File(args[1]);
// this can be used to organize and clean a word-list genWordstat(applicationRoot);
// start this with "java -classpath classes yacy -cleanwordlist <word-file> <minlength> <maxlength>" } else if ((args.length == 4) && (args[0].toLowerCase().equals("-cleanwordlist"))) {
final int minlength = Integer.parseInt(args[2]); // this can be used to organize and clean a word-list
final int maxlength = Integer.parseInt(args[3]); // start this with "java -classpath classes yacy -cleanwordlist <word-file> <minlength> <maxlength>"
cleanwordlist(args[1], minlength, maxlength); final int minlength = Integer.parseInt(args[2]);
} else if ((args.length >= 1) && (args[0].toLowerCase().equals("-urldbcleanup"))) { final int maxlength = Integer.parseInt(args[3]);
// generate a url list and save it in a file cleanwordlist(args[1], minlength, maxlength);
if (args.length == 2) applicationRoot= new File(args[1]); } else if ((args.length >= 1) && (args[0].toLowerCase().equals("-urldbcleanup"))) {
urldbcleanup(dataRoot, applicationRoot, "freeworld"); // generate a url list and save it in a file
} else if ((args.length >= 1) && (args[0].toLowerCase().equals("-rwihashlist"))) { if (args.length == 2) applicationRoot= new File(args[1]);
// generate a url list and save it in a file urldbcleanup(dataRoot, applicationRoot, "freeworld");
String domain = "all"; } else if ((args.length >= 1) && (args[0].toLowerCase().equals("-rwihashlist"))) {
String format = "txt"; // generate a url list and save it in a file
if (args.length >= 2) domain= args[1]; String domain = "all";
if (args.length >= 3) format= args[2]; String format = "txt";
if (args.length == 4) applicationRoot= new File(args[3]); if (args.length >= 2) domain= args[1];
final String outfile = "rwihashlist_" + System.currentTimeMillis(); if (args.length >= 3) format= args[2];
RWIHashList(dataRoot, applicationRoot, outfile, domain, format); if (args.length == 4) applicationRoot= new File(args[3]);
} else { final String outfile = "rwihashlist_" + System.currentTimeMillis();
if (args.length == 1) applicationRoot= new File(args[0]); RWIHashList(dataRoot, applicationRoot, outfile, domain, format);
startup(dataRoot, applicationRoot, startupMemFree, startupMemTotal, false); } else {
} if (args.length == 1) applicationRoot= new File(args[0]);
startup(dataRoot, applicationRoot, startupMemFree, startupMemTotal, false);
}
} finally {
Log.shutdown();
}
} }
} }

Loading…
Cancel
Save