public class DirServer extends Server {
private final Map<File, DSContext> contexts = new HashMap<File, DSContext>();
- private final File datroot;
+ private final Environment env;
private final Logger logger = Logger.getLogger("dolda.jsvc.scgi.dirserver");
- public DirServer(ServerSocket sk, File datroot) {
+ public DirServer(ServerSocket sk, Environment env) {
super(sk);
- this.datroot = datroot;
+ this.env = env;
}
private DSContext context(File file) throws ThreadContext.CreateException {
String act = "loaded %s as %s";
if(ctx != null) {
if(ctx.mtime < file.lastModified()) {
- ctx.tg.destroy();
+ ctx.tg.shutdown();
contexts.remove(file);
ctx = null;
act = "reloaded %s as %s";
}
}
if(ctx == null) {
- ctx = new DSContext(file, datroot);
+ ctx = new DSContext(file, env);
contexts.put(file, ctx);
logger.config(String.format(act, file, ctx.name()));
}
usage(System.err);
System.exit(1);
}
- if(datroot == null) {
- datroot = new File(System.getProperty("user.home"), ".jsvc");
- if(!datroot.exists() || !datroot.isDirectory())
- datroot = null;
- }
+ Environment env = (datroot == null)?new Environment():new Environment(datroot);
+ env.initvm();
int port = Integer.parseInt(opt.rest[0]);
ServerSocket sk;
try {
System.exit(1);
return; /* Because javac is stupid. :-/ */
}
- DirServer s = new DirServer(sk, datroot);
+ DirServer s = new DirServer(sk, env);
if(charset != null)
s.headcs = charset;