简体   繁体   English

Java服务包装器-保持运行和停止

[英]Java service wrapper - Keep run and stopped

This is the logs file, apprently the services work . 这是日志文件,显然是服务工作。 The line file created is printed from my program. 从我的程序中打印创建的行文件。 But it just fail to stay. 但是它只是无法停留。 What wrongs with my config ? 我的配置有什么问题? been trying for a while but no clue 尝试了一段时间,但没有头绪

STATUS | wrapper  | 2014/04/01 11:38:58 | Launching a JVM...
INFO   | jvm 1    | 2014/04/01 11:38:58 | file created
ERROR  | wrapper  | 2014/04/01 11:38:58 | JVM exited while loading the application.
STATUS | wrapper  | 2014/04/01 11:39:02 | Launching a JVM...
INFO   | jvm 2    | 2014/04/01 11:39:03 | file created
ERROR  | wrapper  | 2014/04/01 11:39:03 | JVM exited while loading the application.
STATUS | wrapper  | 2014/04/01 11:39:07 | Launching a JVM...
INFO   | jvm 3    | 2014/04/01 11:39:07 | file created
ERROR  | wrapper  | 2014/04/01 11:39:07 | JVM exited while loading the application.
STATUS | wrapper  | 2014/04/01 11:39:12 | Launching a JVM...
INFO   | jvm 4    | 2014/04/01 11:39:12 | file created
ERROR  | wrapper  | 2014/04/01 11:39:12 | JVM exited while loading the application.
STATUS | wrapper  | 2014/04/01 11:39:17 | Launching a JVM...
INFO   | jvm 5    | 2014/04/01 11:39:17 | file created
ERROR  | wrapper  | 2014/04/01 11:39:17 | JVM exited while loading the application.
FATAL  | wrapper  | 2014/04/01 11:39:17 | There were 5 failed launches in a row, each lasting less than 300 seconds.  Giving up.
FATAL  | wrapper  | 2014/04/01 11:39:17 |   There may be a configuration problem: please check the logs.
STATUS | wrapper  | 2014/04/01 11:39:17 | <-- Wrapper Stopped

Code

    public static void main(String[] args) throws IOException {
    ServerSocket listener = new ServerSocket(3002);
        System.out.println("server started");
    try {
        while (true) {
            Socket socket = listener.accept();
            try {
                PrintWriter out =new PrintWriter(socket.getOutputStream(), true);
                out.println(new Date().toString()+"\ntest");
            } finally {
                socket.close();
            }
        }
    }
    finally {
        listener.close();
    }
}

Conf file Conf文件

#********************************************************************
# Wrapper Java Properties
#********************************************************************
# Java Application
#  Locate the java binary on the system PATH:
wrapper.java.command=java
#  Specify a specific java binary:
#set.JAVA_HOME=/java/path
#wrapper.java.command=%JAVA_HOME%/bin/java

# Tell the Wrapper to log the full generated Java command line.
#wrapper.java.command.loglevel=INFO

# Java Main class.  This class must implement the WrapperListener interface
#  or guarantee that the WrapperManager class is initialized.  Helper
#  classes are provided to do this for you.  See the Integration section
#  of the documentation for details.
wrapper.java.mainclass=HelloWorldServer

# Java Classpath (include wrapper.jar)  Add class path elements as
#  needed starting from 1
wrapper.java.classpath.1=../lib/wrapper.jar
wrapper.java.classpath.2=../lib/classes
wrapper.java.classpath.3=../dist/HelloWorldServer.jar

# Java Library Path (location of Wrapper.DLL or libwrapper.so)
wrapper.java.library.path.1=../lib

# Java Bits.  On applicable platforms, tells the JVM to run in 32 or 64-bit mode.
wrapper.java.additional.auto_bits=TRUE

# Java Additional Parameters
wrapper.java.additional.1=

# Initial Java Heap Size (in MB)
#wrapper.java.initmemory=3

# Maximum Java Heap Size (in MB)
#wrapper.java.maxmemory=64

# Application parameters.  Add parameters as needed starting from 1
#wrapper.app.parameter.1=HelloWorldServer

You need to set main class to one of wrapper classes . 您需要将主类设置为包装器类之一 Basically add following to your wrapper.conf : 基本上将以下内容添加到wrapper.conf

wrapper.java.mainclass=org.tanukisoftware.wrapper.WrapperSimpleApp
wrapper.app.parameter.1=HelloWorldServer

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM