123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117 |
- /*
- * This program is free software: you can redistribute it and/or modify it under
- * the terms of the GNU General Public License as published by the Free Software
- * Foundation, either version 3 of the License, or (at your option) any later
- * version.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
- * details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program. If not, see <http://www.gnu.org/licenses/>.
- */
- package com.l2jserver.communityserver;
- import java.io.File;
- import java.io.FileInputStream;
- import java.io.IOException;
- import java.io.InputStream;
- import java.sql.SQLException;
- import java.util.logging.LogManager;
- import java.util.logging.Logger;
- import com.l2jserver.communityserver.cache.HtmCache;
- import com.l2jserver.communityserver.network.GameServerListener;
- import com.l2jserver.communityserver.network.netcon.NetConnectionConfig;
- import com.l2jserver.communityserver.threading.ThreadPoolManager;
- import com.l2jserver.communityserver.Shutdown;
- public final class L2CommunityServer
- {
- private static final Logger _log = Logger.getLogger(L2CommunityServer.class.getName());
-
- private static L2CommunityServer _instance;
-
- public static final L2CommunityServer getInstance()
- {
- return _instance;
- }
-
- public static final void main(final String[] args)
- {
- _instance = new L2CommunityServer();
- }
-
- private GameServerListener _listener;
- private final Shutdown _shutdownHandler;
-
- public L2CommunityServer()
- {
- final String LOG_FOLDER = "log";
- final String LOG_NAME = "./log.cfg";
-
- File logFolder = new File(Config.DATAPACK_ROOT, LOG_FOLDER);
- logFolder.mkdir();
-
- InputStream is = null;
- try
- {
- is = new FileInputStream(new File(LOG_NAME));
- LogManager.getLogManager().readConfiguration(is);
- is.close();
- }
- catch (IOException e)
- {
- e.printStackTrace();
- }
- finally
- {
- try
- {
- if (is != null)
- {
- is.close();
- }
- }
- catch (IOException e)
- {
- e.printStackTrace();
- }
- }
-
- Config.load();
-
- _shutdownHandler = Shutdown.getInstance();
- Runtime.getRuntime().addShutdownHook(_shutdownHandler);
- ThreadPoolManager.init();
-
- GameServerRegistrationTable.getInstance();
-
- try
- {
- L2DatabaseFactory.getInstance();
- }
- catch (SQLException e)
- {
- _log.severe("FATAL: Failed initializing database. Reason: "+e.getMessage());
- System.exit(1);
- }
-
- // load htm cache
- HtmCache.getInstance();
- try
- {
- _listener = new GameServerListener(new NetConnectionConfig(Config.CONFIGURATION_FILE));
- _listener.start();
- _log.info("Listening for GameServers on " + Config.GAME_SERVER_LOGIN_HOST + ":" + Config.GAME_SERVER_LOGIN_PORT);
- }
- catch (Exception e)
- {
- _log.severe("FATAL: Failed to start the Game Server Listener. Reason: " + e.getMessage());
- e.printStackTrace();
- System.exit(1);
- }
- }
- }
|