跳到主要内容

多服多进程启动

提示

在部署方面,ioGame 支持多服单进程的方式部署,也支持多服多进程多机器的方式部署,在部署方式上可以随意的切换而不需要更改代码。 日常中我们可以按照单体思维开发,到了生产可以选择性的使用多进程的方式部署。

介绍

我们可以让游戏对外服、游戏网关、游戏逻辑服在不同的进程中启动。

启动游戏网关

public static void main(String[] args) throws Exception {
BrokerServer brokerServer = new MyBrokerServer().createBrokerServer();
brokerServer.startup();

TimeUnit.SECONDS.sleep(1);
}

启动游戏逻辑服

public static void main(String[] args) {
WeatherLogicStartup weatherLogicStartup = new WeatherLogicStartup();
BrokerClientApplication.start(weatherLogicStartup);
}

启动游戏对外服

public static void main(String[] args) {
ExternalServer externalServer = new MyExternalServer()
.createExternalServer(ExternalGlobalConfig.externalPort);

externalServer.startup();
}

Example Source Code

see https://github.com/iohao/ioGameExamples

path : SimpleExample/example-multiple

  • MyBrokerServer
  • WeatherLogicStartupApplication
  • MyExternalServer