aboutsummaryrefslogtreecommitdiff
path: root/src/Main.java
blob: 69c029c6130374a6370048e223890c7a7a4a61dd (plain)
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
import org.traccar.Server;
import org.traccar.helper.Log;

public class Main {

    public static void main(String[] args) throws Exception {
    	
    	final Server service = new Server();
    	
    	if(args.length > 0){
    		Log.info("Using parameterized config: " + args[0]);
    		service.init(args);
    	}
    	else{
    		String[] argsDefault = new String[]{"setup\\windows\\windows.cfg"}; 
    		Log.info("Using default config: " + argsDefault[0]);
    		service.init(argsDefault);	
    	}
        
        Log.info("starting server...");
    	
        service.start();
        
        // Shutdown server properly
        Runtime.getRuntime().addShutdownHook(new Thread() {
            @Override
            public void run() {
                Log.info("shutting down server...");
                service.stop();
            }
        });

    }
}