summaryrefslogtreecommitdiffstats
path: root/Dozentenmodulserver/src/main/java/server/StartServer.java
blob: 7280ee99a336c728f0c01e3c7edf20d959ab71f5 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
package server;

import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import models.Configuration;
import org.apache.log4j.BasicConfigurator;
import org.apache.log4j.Logger;
import org.ini4j.InvalidFileFormatException;
import org.ini4j.Wini;
import server.BinaryListener;


public class StartServer {

	/**
	 * @param args
	 */

	private static Logger log = Logger.getLogger(StartServer.class);

	private static List<Thread> servers = new ArrayList<>();

	public static void main(String[] args) {

		String version = "Version: 1.03";
		String buildDate = "Build Date: 09.09.2014";

		//get going and show basic information in logfile
		BasicConfigurator.configure();
		log.info("***** " + new Date() + " - starting Application *****");
		log.info(new Date() + " - "+version+" , "+buildDate);
		
		

		// get Configuration
		try {
			log.info(new Date() + " - Getting config from .ini-file");
			Wini ini = new Wini(new File("Server_Config.ini"));
			Configuration.config.setAbsolute_path(ini.get("ftp",
					"path_absolute"));
			Configuration.config
					.setSql_connection(ini.get("sql", "connection"));
			Configuration.config.setSql_pass(ini.get("sql", "pass"));
			Configuration.config.setSql_user(ini.get("sql", "user"));
		} catch (InvalidFileFormatException e1) {
			// TODO Auto-generated catch block
			e1.printStackTrace();
		} catch (IOException e1) {
			// TODO Auto-generated catch block
			e1.printStackTrace();
		}
		// Start Server
		Thread t;
		t = new Thread(new BinaryListener());
		servers.add(t);
		t.start();
		for (Thread wait : servers) {
			boolean success = false;
			while (!success) {
				try {
					wait.join();
					success = true;
				} catch (InterruptedException e) {
					// Do nothing...
				}
			}
		}
		log.info(new Date() + " - all Servers shut down, exiting...\n");

	}

}