Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/actionscript-3/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java NanoHTTP作为windows服务与Apache Commons守护程序_Java_Nanohttpd_Apache Commons Daemon - Fatal编程技术网

Java NanoHTTP作为windows服务与Apache Commons守护程序

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;

我用NanoHTTP库制作了一个小型HTTP侦听器,我想将它与ApacheCommons守护程序()一起使用,以ProLUN作为Windows服务安装。 我阅读了文档,但我不明白如何在单独的流程中管理开始-停止作业。如何从另一个单独的Java进程停止NanoHTTPD

这是我扩展NanoHTTPD的类:

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来调用您的服务器。我建议使用命名管道或插座