18045010223
21 小时以前 39d4048dc6fd5a138bd1128c06bccca08fbc72f0
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
package cn.org.hentai.jtt1078.app;
 
import cn.org.hentai.jtt1078.publisher.PublishManager;
import cn.org.hentai.jtt1078.server.SessionManager;
import cn.org.hentai.jtt1078.util.Configs;
import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct;
import javax.annotation.Resource;
 
@Component
public class ServerApp {
 
    @Resource
    private VideoServer videoServer;
    @Resource
    private HttpServer httpServer;
    @Resource
    private TalkServer talkServer;
    @PostConstruct
    public void start() throws Exception {
        // 初始化配置、管理器(可提取成 ConfigService 由 Spring 管理)
        Configs.init("/app.properties");
        PublishManager.init();
        SessionManager.init();
        videoServer.start();
        httpServer.start();
        talkServer.start();
        // 注册优雅关闭(也可用 Spring 的 DisposableBean、@PreDestroy)
        sun.misc.Signal.handle(new sun.misc.Signal("TERM"), signal -> {
            videoServer.shutdown();
            httpServer.shutdown();
        });
    }
}