kstyrc / embedded-redis

Redis embedded server for Java integration testing
840 stars 368 forks source link

Incorrect process name when started on mac. #44

Open gochev opened 9 years ago

gochev commented 9 years ago

I am starting redis embedded as part of spring-boot application(which is a product). However after starting the redis instead of my product name I see redis in the tab.

I am starting embedded tomcat, solr, and redis... however the tab stays saying redis

see attached screenshot screen shot 2015-04-14 at 14 02 14

kstyrc commented 9 years ago

How to reproduce the issue? How do you run it exactly?

gochev commented 9 years ago

We have a spring boot application and we import the following configuration that starts the embedded redis.

@Configuration public class PlatformCoreSessionConfig {

@Bean(name = "sessionStrategy")
public HttpSessionStrategy defaultSessionStrategy() {
    final CookieHttpSessionStrategy result = new CookieHttpSessionStrategy();
    result.setCookieName("SESSION");
    return result;
}

@Bean
public static RedisServerBean redisServer() {
    return new RedisServerBean();
}

@Bean(name = { "defaultRedisSessionRepository", "sessionRepository" })
public SessionRepository defaultRedisSessionRepository(JedisConnectionFactory redisCF) throws Exception {
    return new RedisOperationsSessionRepository(redisCF);
}

@Bean
public JedisConnectionFactory connectionFactory(final Environment environment) throws Exception {
    final JedisConnectionFactory jcf = new JedisConnectionFactory();
    jcf.setHostName(environment.getProperty("platform.redis.host", String.class, "localhost"));
    jcf.setPort(environment.getProperty("platform.redis.port", Integer.class, Protocol.DEFAULT_PORT));
    jcf.setPassword(environment.getProperty("platform.redis.password", String.class, ""));
    jcf.afterPropertiesSet();

    return jcf;
}

/**
 * Implements BeanDefinitionRegistryPostProcessor to ensure this Bean
 * is initialized before any other Beans. Specifically, we want to ensure
 * that the Redis Server is started before RedisHttpSessionConfiguration
 * attempts to enable Keyspace notifications.
 */
static class RedisServerBean implements InitializingBean, DisposableBean, BeanDefinitionRegistryPostProcessor {
    private RedisServer redisServer;

    public void afterPropertiesSet() throws Exception {
        redisServer = new RedisServer(Protocol.DEFAULT_PORT);
        redisServer.start();
    }

    public void destroy() throws Exception {
        if (redisServer != null) {
            redisServer.stop();
        }
    }

    public void postProcessBeanDefinitionRegistry(BeanDefinitionRegistry registry) throws BeansException {
    }

    public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
    }
}

}