1
0
mirror of https://gitee.com/mirrors/Spring-Cloud-Alibaba.git synced 2021-06-26 13:25:11 +08:00

sync code from master

This commit is contained in:
flystar32
2019-04-17 00:20:28 +08:00
parent 24ec156dc6
commit a0775255c9
66 changed files with 427 additions and 335 deletions

View File

@@ -73,31 +73,4 @@ public class NacosDiscoveryAutoConfiguration {
return new NacosAutoServiceRegistration(registry,
autoServiceRegistrationProperties, registration);
}
@Bean
@ConditionalOnBean(NacosAutoServiceRegistration.class) // NacosAutoServiceRegistration
// should be present
@ConditionalOnNotWebApplication // Not Web Application
public ApplicationRunner applicationRunner(
final NacosAutoServiceRegistration nacosAutoServiceRegistration) {
return new ApplicationRunner() {
@Override
public void run(ApplicationArguments args) throws Exception {
if (!nacosAutoServiceRegistration.isRunning()) { // If it's not running,
// let
// it start.
// FIXME: Please make sure "spring.cloud.nacos.discovery.port" must be
// configured on an available port,
// or the startup or Nacos health check will be failed.
nacosAutoServiceRegistration.start();
// NacosAutoServiceRegistration will be stopped after its destroy()
// method
// is invoked.
// @PreDestroy destroy() -> stop()
}
}
};
}
}

View File

@@ -18,6 +18,7 @@ package org.springframework.cloud.alibaba.nacos;
import com.alibaba.nacos.api.NacosFactory;
import com.alibaba.nacos.api.naming.NamingService;
import com.alibaba.nacos.api.naming.PreservedMetadataKeys;
import com.alibaba.nacos.client.naming.utils.UtilAndComs;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -67,7 +68,7 @@ public class NacosDiscoveryProperties {
/**
* watch delay,duration to pull new service from nacos server.
*/
private long watchDelay = 5000;
private long watchDelay = 30000;
/**
* nacos naming log file name
@@ -149,6 +150,7 @@ public class NacosDiscoveryProperties {
@PostConstruct
public void init() throws SocketException {
metadata.put(PreservedMetadataKeys.REGISTER_SOURCE, "SPRING_CLOUD");
if (secure) {
metadata.put("secure", "true");
}