aaa1934
aaa1934

Reputation: 59

Spring Cloud Config Server Not Refreshing

I'm setting up a Spring cloud server to read of an internal Stash directory.

The server loads up ok the first time, but if I update properties in git, they don't get reflected until I restart cloud server (I try POST to /refresh endpoint).

I'm on Windows and I see a few bugs related to server on Windows but I don't see any specific mention of my bug.

Upvotes: 2

Views: 4148

Answers (1)

j.min
j.min

Reputation: 9

see org.springframework.cloud.bootstrap.config.RefreshEndpoint code here:

public synchronized String[] refresh() {
    Map<String, Object> before = extract(context.getEnvironment()
            .getPropertySources());
    addConfigFilesToEnvironment();
    Set<String> keys = changes(before,
            extract(context.getEnvironment().getPropertySources())).keySet();
    scope.refreshAll();
    if (keys.isEmpty()) {
        return new String[0];
    }
    context.publishEvent(new EnvironmentChangeEvent(keys));
    return keys.toArray(new String[keys.size()]);
}

that means /refresh endpoint pull git first and then refresh catch,and public a environmentChangeEvent,so we can customer the code like this.

Upvotes: 1

Related Questions