-
Notifications
You must be signed in to change notification settings - Fork 2.9k
/
Copy pathCIMServerApplication.java
44 lines (36 loc) · 1.33 KB
/
CIMServerApplication.java
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
package com.crossoverjie.cim.server;
import com.crossoverjie.cim.server.config.AppConfiguration;
import com.crossoverjie.cim.server.kit.RegistryZK;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import java.net.InetAddress;
/**
* @author crossoverJie
*/
@SpringBootApplication
public class CIMServerApplication implements CommandLineRunner{
private final static Logger LOGGER = LoggerFactory.getLogger(CIMServerApplication.class);
@Autowired
private AppConfiguration appConfiguration ;
@Value("${server.port}")
private int httpPort ;
@Value("${cim.server.weight}")
private int weight;
public static void main(String[] args) {
SpringApplication.run(CIMServerApplication.class, args);
LOGGER.info("启动 Server 成功");
}
@Override
public void run(String... args) throws Exception {
//获得本机IP
String addr = InetAddress.getLocalHost().getHostAddress();
Thread thread = new Thread(new RegistryZK(addr, appConfiguration.getCimServerPort(),httpPort,weight));
thread.setName("registry-zk");
thread.start() ;
}
}