resin.preConfigureInit();
// XXX: needs to be config
InjectManager cdiManager = InjectManager.create();
Config.setProperty("resinHome", elContext.getResinHome());
Config.setProperty("resin", elContext.getResinVar());
Config.setProperty("server", elContext.getServerVar());
Config.setProperty("java", elContext.getJavaVar());
Config.setProperty("system", System.getProperties());
Config.setProperty("getenv", System.getenv());
ResinConfigLibrary.configure(cdiManager);
_watchdogPort = _args.getWatchdogPort();
readConfig(_args);
WatchdogChild server = null;
String serverId = _args.getServerId();
if (_args.isDynamicServer()) {
serverId = _args.getDynamicServerId();
}
server = _watchdogMap.get(_args.getServerId());
if (server == null)
throw new IllegalStateException(L().l("'{0}' is an unknown server",
serverId));
JniBoot boot = new JniBoot();
Path logDirectory = getLogDirectory();
if (boot.isValid()) {
if (! isLogDirectoryExists) {
logDirectory.mkdirs();
boot.chown(logDirectory, server.getUserName(), server.getGroupName());
}
}
server.getConfig().logInit(logStream);
resin.preConfigureInit();
resin.setConfigFile(_args.getResinConf().getNativePath());
thread = Thread.currentThread();
thread.setContextClassLoader(resin.getClassLoader());
CloudSystem cloudSystem = TopologyService.getCurrent().getSystem();
CloudCluster cluster = cloudSystem.createCluster("watchdog");
CloudPod pod = cluster.createPod();
pod.createStaticServer("default", "localhost", -1, false);
_server = resin.createServer();
thread.setContextClassLoader(_server.getClassLoader());
NetworkListenSystem listenService
= _system.getService(NetworkListenSystem.class);
_httpPort = new TcpSocketLinkListener();
_httpPort.setProtocol(new HttpProtocol());
if (_watchdogPort > 0)
_httpPort.setPort(_watchdogPort);
else
_httpPort.setPort(server.getWatchdogPort());
_httpPort.setAddress(server.getWatchdogAddress());
_httpPort.setAcceptThreadMin(2);
_httpPort.setAcceptThreadMax(3);
_httpPort.init();
listenService.addListener(_httpPort);
ClassLoader oldLoader = thread.getContextClassLoader();
try {
thread.setContextClassLoader(_system.getClassLoader());
cdiManager = InjectManager.create();
AdminAuthenticator auth = null;
if (_management != null)
auth = _management.getAdminAuthenticator();
if (auth != null) {
BeanBuilder<Authenticator> factory = cdiManager.createBeanFactory(Authenticator.class);
factory.type(Authenticator.class);
factory.type(AdminAuthenticator.class);
factory.qualifier(DefaultLiteral.DEFAULT);
cdiManager.addBean(factory.singleton(auth));
}
DependencyCheckInterval depend = new DependencyCheckInterval();
depend.setValue(new Period(-1));
depend.init();