Java NanoHTTP作为windows服务与Apache Commons守护程序
我用NanoHTTP库制作了一个小型HTTP侦听器,我想将它与ApacheCommons守护程序()一起使用,以ProLUN作为Windows服务安装。 我阅读了文档,但我不明白如何在单独的流程中管理开始-停止作业。如何从另一个单独的Java进程停止NanoHTTPD 这是我扩展NanoHTTPD的类:Java NanoHTTP作为windows服务与Apache Commons守护程序,java,nanohttpd,apache-commons-daemon,Java,Nanohttpd,Apache Commons Daemon,我用NanoHTTP库制作了一个小型HTTP侦听器,我想将它与ApacheCommons守护程序()一起使用,以ProLUN作为Windows服务安装。 我阅读了文档,但我不明白如何在单独的流程中管理开始-停止作业。如何从另一个单独的Java进程停止NanoHTTPD 这是我扩展NanoHTTPD的类: public class PrintServer extends NanoHTTPD { private static final int SERVER_PORT=11100;
public class PrintServer extends NanoHTTPD {
private static final int SERVER_PORT=11100;
private static final String MIMEJSON = "application/json";
public PrintServer() throws IOException {
super(SERVER_PORT);
start(NanoHTTPD.SOCKET_READ_TIMEOUT, false);
log.info("Cinebot PrintServer avviato e in ascolto su porta {}",SERVER_PORT);
}
public static void main(String[] args) {
try {
new PrintServer();
} catch (IOException ioe) {
log.error("Non posso avviare PrintServer", ioe);
}
}
@Override
public Response serve(IHTTPSession session) {
return newFixedLengthResponse(Response.Status.OK, MIMEJSON, null);
}
}
apache守护进程是否需要第二个可执行文件?如果是,您必须使用main和任何IPC技术创建另一个java来调用您的服务器。我建议使用命名管道或插座