Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ fi

NAME="$(basename $0)"
stop() {
SHUTDOWN_WAIT="30"
SHUTDOWN_WAIT="40"
count="0"
if [ -f /var/run/cloud-management.pid ]; then
pid=`cat /var/run/cloud-management.pid`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ public void stopBeans() {
with(new WithComponentLifeCycle() {
@Override
public void with(ComponentLifecycle lifecycle) {
log.info("stopping bean " + lifecycle.getName());
lifecycle.stop();
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Map;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down Expand Up @@ -71,10 +72,14 @@ public void init() throws IOException {
}

public void registerShutdownHook() {
ApplicationContext base = moduleDefinitionSet.getApplicationContext(baseName);
Map<String, ApplicationContext> contextMap= moduleDefinitionSet.getContextMap();

if (base instanceof ConfigurableApplicationContext) {
((ConfigurableApplicationContext)base).registerShutdownHook();
for (String appName : contextMap.keySet()) {
ApplicationContext contex = contextMap.get(appName);
if (contex instanceof ConfigurableApplicationContext) {
log.trace("registering shutdown hook for bean "+ appName);
((ConfigurableApplicationContext)contex).registerShutdownHook();
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,16 @@
import org.springframework.context.ApplicationContext;
import org.springframework.core.io.Resource;

import java.util.Map;

public interface ModuleDefinitionSet {

ModuleDefinition getModuleDefinition(String name);

ApplicationContext getApplicationContext(String name);

Map<String, ApplicationContext> getContextMap();

Resource[] getConfigResources(String name);

}
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,11 @@ public ApplicationContext getApplicationContext(String name) {
return contexts.get(name);
}

@Override
public Map<String, ApplicationContext> getContextMap() {
return contexts;
}

@Override
public Resource[] getConfigResources(String name) {
Set<Resource> resources = new LinkedHashSet<Resource>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ protected ApplicationContext loadParentContext(ServletContext servletContext) {
public void contextInitialized(ServletContextEvent event) {
try {
cloudStackContext = new CloudStackSpringContext();
cloudStackContext.registerShutdownHook();
event.getServletContext().setAttribute(CloudStackSpringContext.CLOUDSTACK_CONTEXT_SERVLET_KEY, cloudStackContext);
} catch (IOException e) {
log.error("Failed to start CloudStack", e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,9 @@ public boolean start() {

@Override
public boolean stop() {
_dbSyncTimer.cancel();
if (_dbSyncTimer != null) {
_dbSyncTimer.cancel();
}
return true;
}

Expand Down