定时检查配置文件
parent
c6aa139152
commit
5c31c6263a
|
|
@ -1,6 +1,5 @@
|
||||||
package com.ljsd;
|
package com.ljsd;
|
||||||
|
|
||||||
import com.ljsd.jieling.config.json.ConfMessage;
|
|
||||||
import com.ljsd.jieling.config.json.ServerConfiguration;
|
import com.ljsd.jieling.config.json.ServerConfiguration;
|
||||||
import com.ljsd.jieling.config.json.ServerProperties;
|
import com.ljsd.jieling.config.json.ServerProperties;
|
||||||
import com.ljsd.jieling.db.redis.RedisUtil;
|
import com.ljsd.jieling.db.redis.RedisUtil;
|
||||||
|
|
@ -48,10 +47,7 @@ public class GameApplication {
|
||||||
configurableApplicationContext = app.run(args);
|
configurableApplicationContext = app.run(args);
|
||||||
ServerConfiguration serverConfiguration = configurableApplicationContext.getBean(ServerConfiguration.class);
|
ServerConfiguration serverConfiguration = configurableApplicationContext.getBean(ServerConfiguration.class);
|
||||||
serverProperties = serverConfiguration.getServerProperties();
|
serverProperties = serverConfiguration.getServerProperties();
|
||||||
|
serverId = serverProperties.getId();
|
||||||
//加载配置开关
|
|
||||||
ConfMessage.doWork();
|
|
||||||
|
|
||||||
//注册消息处理方法
|
//注册消息处理方法
|
||||||
ProtocolsManager protocolsManager = ProtocolsManager.getInstance();
|
ProtocolsManager protocolsManager = ProtocolsManager.getInstance();
|
||||||
// protocolsManager.initContext();
|
// protocolsManager.initContext();
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
package com.ljsd.jieling.thread;
|
package com.ljsd.jieling.thread;
|
||||||
|
|
||||||
import com.ljsd.jieling.thread.task.TestTask;
|
import com.ljsd.jieling.thread.task.PlatConfigureTask;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.context.ConfigurableApplicationContext;
|
import org.springframework.context.ConfigurableApplicationContext;
|
||||||
|
|
@ -15,14 +15,14 @@ public class ThreadManager {
|
||||||
private static final Logger LOGGER = LoggerFactory.getLogger(ThreadManager.class);
|
private static final Logger LOGGER = LoggerFactory.getLogger(ThreadManager.class);
|
||||||
|
|
||||||
|
|
||||||
private TestTask testTask;
|
private PlatConfigureTask testTask;
|
||||||
|
|
||||||
|
|
||||||
private ScheduledThreadPoolExecutor scheduledExecutor; //管理task
|
private ScheduledThreadPoolExecutor scheduledExecutor; //管理task
|
||||||
|
|
||||||
public void init(ConfigurableApplicationContext configurableApplicationContext) {
|
public void init(ConfigurableApplicationContext configurableApplicationContext) {
|
||||||
|
|
||||||
testTask = configurableApplicationContext.getBean(TestTask.class);
|
testTask = configurableApplicationContext.getBean(PlatConfigureTask.class);
|
||||||
|
|
||||||
go();
|
go();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,33 @@
|
||||||
|
package com.ljsd.jieling.thread.task;
|
||||||
|
|
||||||
|
import com.ljsd.jieling.config.json.ConfMessage;
|
||||||
|
import com.ljsd.jieling.util.TimeUtils;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
public class PlatConfigureTask implements Runnable {
|
||||||
|
|
||||||
|
private static final Logger LOGGER = LoggerFactory.getLogger(PlatConfigureTask.class);
|
||||||
|
private int SLEEP_INTEVAL_TIME = 60 * 1000; //每1分钟检查一次
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
doLogic();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void doLogic() {
|
||||||
|
while (true){
|
||||||
|
try {
|
||||||
|
ConfMessage.doWork();
|
||||||
|
TimeUtils.sleep(SLEEP_INTEVAL_TIME);
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,24 +0,0 @@
|
||||||
package com.ljsd.jieling.thread.task;
|
|
||||||
|
|
||||||
import com.ljsd.jieling.db.redis.RedisUtil;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
@Component
|
|
||||||
public class TestTask implements Runnable {
|
|
||||||
|
|
||||||
private static final Logger LOGGER = LoggerFactory.getLogger(TestTask.class);
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
doLogic();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void doLogic() {
|
|
||||||
long str = RedisUtil.getInstence().incr("TestTask",1L);
|
|
||||||
LOGGER.info("--> RedisUtil.incr : str = "+str);
|
|
||||||
LOGGER.info("TestTask ... ");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue