chris@0: /*
chris@0: * StarOffice News Server
chris@0: * see AUTHORS for the list of contributors
chris@0: *
chris@0: * This program is free software: you can redistribute it and/or modify
chris@0: * it under the terms of the GNU General Public License as published by
chris@0: * the Free Software Foundation, either version 3 of the License, or
chris@0: * (at your option) any later version.
chris@0: *
chris@0: * This program is distributed in the hope that it will be useful,
chris@0: * but WITHOUT ANY WARRANTY; without even the implied warranty of
chris@0: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
chris@0: * GNU General Public License for more details.
chris@0: *
chris@0: * You should have received a copy of the GNU General Public License
chris@0: * along with this program. If not, see .
chris@0: */
chris@0:
chris@0: package com.so.news;
chris@0:
chris@0: import java.net.BindException;
chris@0:
chris@0: import java.sql.Driver;
chris@0: import java.sql.DriverManager;
chris@0: import java.util.Enumeration;
chris@0:
chris@0: import com.so.news.storage.Database;
chris@0: import com.so.news.storage.Purger;
chris@0:
chris@0: /**
chris@0: * Startup class of the daemon.
chris@0: * @author Christian Lins
chris@0: */
chris@0: public class Main
chris@0: {
chris@0: /** Version information of the StarOffice News daemon */
chris@0: public static final String VERSION = "StarOffice News Server 0.5alpha1";
chris@0:
chris@0: /**
chris@0: * The main entrypoint.
chris@0: * @param args
chris@0: * @throws Exception
chris@0: */
chris@0: public static void main(String args[]) throws Exception
chris@0: {
chris@0: System.out.println(VERSION);
chris@0:
chris@0: // Command line arguments
chris@0: boolean auxPort = false;
chris@0:
chris@0: for(int n = 0; n < args.length; n++)
chris@0: {
chris@0: if(args[n].equals("--dumpjdbcdriver"))
chris@0: {
chris@0: System.out.println("Available JDBC drivers:");
chris@0: Enumeration drvs = DriverManager.getDrivers();
chris@0: while(drvs.hasMoreElements())
chris@0: System.out.println(drvs.nextElement());
chris@0: return;
chris@0: }
chris@0: else if(args[n].equals("--useaux"))
chris@0: auxPort = true;
chris@0: }
chris@0:
chris@0: // Try to load the Database
chris@0: try
chris@0: {
chris@0: Database.arise();
chris@0: }
chris@0: catch(Exception ex)
chris@0: {
chris@0: ex.printStackTrace(Debug.getInstance().getStream());
chris@0: System.err.println("Database initialization failed with " + ex.toString());
chris@0:
chris@0: return;
chris@0: }
chris@0:
chris@0: // Start the n3tpd garbage collector
chris@0: new Purger().start();
chris@0:
chris@0: // Start the listening daemon
chris@0: try
chris@0: {
chris@0: new NNTPDaemon(false).start();
chris@0: }
chris@0: catch(BindException ex)
chris@0: {
chris@0: ex.printStackTrace(Debug.getInstance().getStream());
chris@0: System.err.println("Could not bind to interface. Perhaps you need superuser rights?");
chris@0: }
chris@0:
chris@0: // Start auxilary listening port...
chris@0: if(auxPort)
chris@0: new NNTPDaemon(true).start();
chris@0: }
chris@0: }