author | chris <chris@marvin> |
Tue, 20 Jan 2009 10:21:03 +0100 | |
changeset 0 | f907866f0e4b |
permissions | -rw-r--r-- |
chris@0 | 1 |
/* |
chris@0 | 2 |
* StarOffice News Server |
chris@0 | 3 |
* see AUTHORS for the list of contributors |
chris@0 | 4 |
* |
chris@0 | 5 |
* This program is free software: you can redistribute it and/or modify |
chris@0 | 6 |
* it under the terms of the GNU General Public License as published by |
chris@0 | 7 |
* the Free Software Foundation, either version 3 of the License, or |
chris@0 | 8 |
* (at your option) any later version. |
chris@0 | 9 |
* |
chris@0 | 10 |
* This program is distributed in the hope that it will be useful, |
chris@0 | 11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
chris@0 | 12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
chris@0 | 13 |
* GNU General Public License for more details. |
chris@0 | 14 |
* |
chris@0 | 15 |
* You should have received a copy of the GNU General Public License |
chris@0 | 16 |
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
chris@0 | 17 |
*/ |
chris@0 | 18 |
|
chris@0 | 19 |
package com.so.news; |
chris@0 | 20 |
|
chris@0 | 21 |
import java.net.BindException; |
chris@0 | 22 |
|
chris@0 | 23 |
import java.sql.Driver; |
chris@0 | 24 |
import java.sql.DriverManager; |
chris@0 | 25 |
import java.util.Enumeration; |
chris@0 | 26 |
|
chris@0 | 27 |
import com.so.news.storage.Database; |
chris@0 | 28 |
import com.so.news.storage.Purger; |
chris@0 | 29 |
|
chris@0 | 30 |
/** |
chris@0 | 31 |
* Startup class of the daemon. |
chris@0 | 32 |
* @author Christian Lins |
chris@0 | 33 |
*/ |
chris@0 | 34 |
public class Main |
chris@0 | 35 |
{ |
chris@0 | 36 |
/** Version information of the StarOffice News daemon */ |
chris@0 | 37 |
public static final String VERSION = "StarOffice News Server 0.5alpha1"; |
chris@0 | 38 |
|
chris@0 | 39 |
/** |
chris@0 | 40 |
* The main entrypoint. |
chris@0 | 41 |
* @param args |
chris@0 | 42 |
* @throws Exception |
chris@0 | 43 |
*/ |
chris@0 | 44 |
public static void main(String args[]) throws Exception |
chris@0 | 45 |
{ |
chris@0 | 46 |
System.out.println(VERSION); |
chris@0 | 47 |
|
chris@0 | 48 |
// Command line arguments |
chris@0 | 49 |
boolean auxPort = false; |
chris@0 | 50 |
|
chris@0 | 51 |
for(int n = 0; n < args.length; n++) |
chris@0 | 52 |
{ |
chris@0 | 53 |
if(args[n].equals("--dumpjdbcdriver")) |
chris@0 | 54 |
{ |
chris@0 | 55 |
System.out.println("Available JDBC drivers:"); |
chris@0 | 56 |
Enumeration<Driver> drvs = DriverManager.getDrivers(); |
chris@0 | 57 |
while(drvs.hasMoreElements()) |
chris@0 | 58 |
System.out.println(drvs.nextElement()); |
chris@0 | 59 |
return; |
chris@0 | 60 |
} |
chris@0 | 61 |
else if(args[n].equals("--useaux")) |
chris@0 | 62 |
auxPort = true; |
chris@0 | 63 |
} |
chris@0 | 64 |
|
chris@0 | 65 |
// Try to load the Database |
chris@0 | 66 |
try |
chris@0 | 67 |
{ |
chris@0 | 68 |
Database.arise(); |
chris@0 | 69 |
} |
chris@0 | 70 |
catch(Exception ex) |
chris@0 | 71 |
{ |
chris@0 | 72 |
ex.printStackTrace(Debug.getInstance().getStream()); |
chris@0 | 73 |
System.err.println("Database initialization failed with " + ex.toString()); |
chris@0 | 74 |
|
chris@0 | 75 |
return; |
chris@0 | 76 |
} |
chris@0 | 77 |
|
chris@0 | 78 |
// Start the n3tpd garbage collector |
chris@0 | 79 |
new Purger().start(); |
chris@0 | 80 |
|
chris@0 | 81 |
// Start the listening daemon |
chris@0 | 82 |
try |
chris@0 | 83 |
{ |
chris@0 | 84 |
new NNTPDaemon(false).start(); |
chris@0 | 85 |
} |
chris@0 | 86 |
catch(BindException ex) |
chris@0 | 87 |
{ |
chris@0 | 88 |
ex.printStackTrace(Debug.getInstance().getStream()); |
chris@0 | 89 |
System.err.println("Could not bind to interface. Perhaps you need superuser rights?"); |
chris@0 | 90 |
} |
chris@0 | 91 |
|
chris@0 | 92 |
// Start auxilary listening port... |
chris@0 | 93 |
if(auxPort) |
chris@0 | 94 |
new NNTPDaemon(true).start(); |
chris@0 | 95 |
} |
chris@0 | 96 |
} |