directory-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Brian Wallis <brian.wal...@infomedix.com.au>
Subject Re: stop and restart embedded server (1.0.2)
Date Tue, 28 Aug 2007 03:02:55 GMT

On 27/08/2007, at 9:35 AM, Brian Wallis wrote:
>
> I am starting up three apacheds instances on different ports and  
> then I want to stop and restart them as required for the various  
> test scenarios. I cannot work out how to do this. I am using the  
> following to stop the servers and it does seem to stop them.
>
>     Hashtable env = new Hashtable();
>     env.putAll(new ShutdownConfiguration 
> (instanceName).toJndiEnvironment());
>     env.put(Context.PROVIDER_URL, "ou=system");
>     env.put(Context.INITIAL_CONTEXT_FACTORY,  
> "org.apache.directory.server.jndi.ServerContextFactory");
>     env.put(Context.SECURITY_PRINCIPAL, "uid=admin,ou=system");
>     env.put(Context.SECURITY_CREDENTIALS, "secret");
>     new InitialDirContext(env);
>
> but I cannot work out how to restart the server again.

I have discovered now that if I start three embedded servers (and  
test them, all respond OK on their associated ldap ports) and then  
shutdown the last one I started using the above code it stops all  
three of them which is not quite what I was expecting. The above code  
seems to stop listening on all three ports not just the one started  
with the name in 'instanceName'.

I think I'm missing something here.

The startup code is like this: (some bits deleted that load an ldif  
file and create a new partition)


    instanceName = "instance_" + port;
    MutableServerStartupConfiguration configuration = new
            MutableServerStartupConfiguration(instanceName);
    workingDir = new File(System.getProperty("java.io.tmpdir") +
            configuration.getWorkingDirectory().getPath() + "." + port);
    configuration.setWorkingDirectory(workingDir);
    doDelete(configuration.getWorkingDirectory()); // cleanup before  
starting

    configuration.setLdapPort(port);
    configuration.setEnableNetworking(true);
    configuration.setShutdownHookEnabled(false);
    configuration.setAllowAnonymousAccess(false);
    configuration.setAccessControlEnabled(false);
    configuration.setEnableChangePassword(false);
// ...
// create new partitions and load ldif file
// ....
	Hashtable env = new Hashtable(configuration.toJndiEnvironment());
    env.put(Context.SECURITY_PRINCIPAL, "uid=admin,ou=system");
    env.put(Context.SECURITY_CREDENTIALS, "secret");
    env.put(Context.SECURITY_AUTHENTICATION, "simple");
    env.put(Context.INITIAL_CONTEXT_FACTORY,  
ServerContextFactory.class.getName());
    env.put(Context.PROVIDER_URL, "ou=system");
    sysRoot = new InitialLdapContext(envFinal, null);
    env.put(Context.PROVIDER_URL, "");
    rootDSE = new InitialLdapContext(envFinal, null);



Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message