jsvc & Gradle - 没有控制台输出,Gradle 守护进程崩溃
jsvc & Gradle - no console output, Gradle daemon crashes
我正在尝试在我的本地计算机上使用 IntelliJ IDEA 测试我的 Java 应用程序(它旨在用作守护进程,因此使用 jsvc)。
出于测试目的,我希望将 stdout 和 stderr 都输出到控制台。
根据 jsvc 帮助站点 (jsvc --help) 设置 -outfile '&2'
和 -errfile '&1'
应该将 stdout 和 stderr 重定向到彼此(根据我的理解)。
在正常的 shell(设置了这两个选项)中,守护程序启动并向控制台输出一些内容,但是当使用 Gradle Exec task 和完全相同的命令时 Gradle 守护进程崩溃并输出到文件“&2”和“&1”。
任务配置:
File jsvcFile = file("./jsvc")
File pidFile = file("./jsvc.pid")
String mainClass = "substupdater.SubstUpdater"
task run (dependsOn: [jar, jsvc], type: Exec) {
doFirst {
// Get the absolute path of all libraries
String classPath = project.configurations.compile.join(':')
executable(jsvcFile)
args("-server", "-cp", classPath + ':' + jar.archivePath, "-nodetach",
"-cwd", project.rootDir, "-outfile", "'&2'", "-errfile", "'&1'",
"-pidfile", pidFile, "-procname", project.name, mainClass, "debug")
}
}
Gradle 守护程序崩溃 (gradle -d 运行):
21:57:52.911 [DEBUG] [org.gradle.process.internal.DefaultExecHandle] Changing state to: STARTING
21:57:52.914 [DEBUG] [org.gradle.process.internal.DefaultExecHandle] Waiting until process started: command '/path/to/jsvc'.
21:57:52.924 [DEBUG] [org.gradle.process.internal.DefaultExecHandle] Changing state to: STARTED
21:57:52.925 [INFO] [org.gradle.process.internal.DefaultExecHandle] Successfully started process 'command '/path/to/jsvc''
21:57:52.926 [DEBUG] [org.gradle.process.internal.ExecHandleRunner] waiting until streams are handled...
Daemon vm is shutting down... The daemon has exited normally or was terminated in response to a user interrupt.
21:57:53.528 [DEBUG] [org.gradle.launcher.daemon.registry.PersistentDaemonRegistry] Removing daemon address: [some-address port:35450, addresses:[/0:0:0:0:0:0:0:1%lo, /127.0.0.1]]
21:57:53.529 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Waiting to acquire exclusive lock on daemon addresses registry.
21:57:53.529 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Lock acquired on daemon addresses registry.
21:57:53.530 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Releasing lock on daemon addresses registry.
21:57:53.530 [DEBUG] [org.gradle.process.internal.ExecHandleRunner] Abort requested. Destroying process: command '/path/to/jsvc'.
21:57:53.532 [DEBUG] [org.gradle.process.internal.DefaultExecHandle] Changing state to: ABORTED
21:57:53.533 [DEBUG] [org.gradle.process.internal.DefaultExecHandle] Process 'command '/path/to/jsvc'' finished with exit value 1 (state: ABORTED)
----- End of the daemon log -----
21:57:53.888 [DEBUG] [org.gradle.launcher.daemon.client.DaemonClientInputForwarder] Dispatching close input message: org.gradle.launcher.daemon.protocol.CloseInput@ce9a99
21:57:53.888 [DEBUG] [org.gradle.launcher.daemon.client.DaemonClientConnection] thread 18: dispatching class org.gradle.launcher.daemon.protocol.CloseInput
21:57:53.889 [DEBUG] [org.gradle.launcher.daemon.client.DaemonClientConnection] thread 1: connection stop
21:57:53.907 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]
21:57:53.907 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] FAILURE: Build failed with an exception.
21:57:53.907 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]
21:57:53.908 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] * What went wrong:
21:57:53.908 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] Gradle build daemon disappeared unexpectedly (it may have been killed or may have crashed)
21:57:53.908 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]
21:57:53.908 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] * Try:
21:57:53.908 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] Run with --stacktrace option to get the stack trace.
任何帮助将不胜感激:)
我只需要指定文件描述符符号链接的完整路径(即 /proc/self/fd/1
用于 stdout
和 /proc/self/fd/2
用于 stderr
),现在正在完成输出安慰。
Gradle 守护进程仍然崩溃,但我认为这是由于 Gradle 无法处理 jsvc 守护进程自行终止(?)。
我正在尝试在我的本地计算机上使用 IntelliJ IDEA 测试我的 Java 应用程序(它旨在用作守护进程,因此使用 jsvc)。
出于测试目的,我希望将 stdout 和 stderr 都输出到控制台。
根据 jsvc 帮助站点 (jsvc --help) 设置 -outfile '&2'
和 -errfile '&1'
应该将 stdout 和 stderr 重定向到彼此(根据我的理解)。
在正常的 shell(设置了这两个选项)中,守护程序启动并向控制台输出一些内容,但是当使用 Gradle Exec task 和完全相同的命令时 Gradle 守护进程崩溃并输出到文件“&2”和“&1”。
任务配置:
File jsvcFile = file("./jsvc")
File pidFile = file("./jsvc.pid")
String mainClass = "substupdater.SubstUpdater"
task run (dependsOn: [jar, jsvc], type: Exec) {
doFirst {
// Get the absolute path of all libraries
String classPath = project.configurations.compile.join(':')
executable(jsvcFile)
args("-server", "-cp", classPath + ':' + jar.archivePath, "-nodetach",
"-cwd", project.rootDir, "-outfile", "'&2'", "-errfile", "'&1'",
"-pidfile", pidFile, "-procname", project.name, mainClass, "debug")
}
}
Gradle 守护程序崩溃 (gradle -d 运行):
21:57:52.911 [DEBUG] [org.gradle.process.internal.DefaultExecHandle] Changing state to: STARTING
21:57:52.914 [DEBUG] [org.gradle.process.internal.DefaultExecHandle] Waiting until process started: command '/path/to/jsvc'.
21:57:52.924 [DEBUG] [org.gradle.process.internal.DefaultExecHandle] Changing state to: STARTED
21:57:52.925 [INFO] [org.gradle.process.internal.DefaultExecHandle] Successfully started process 'command '/path/to/jsvc''
21:57:52.926 [DEBUG] [org.gradle.process.internal.ExecHandleRunner] waiting until streams are handled...
Daemon vm is shutting down... The daemon has exited normally or was terminated in response to a user interrupt.
21:57:53.528 [DEBUG] [org.gradle.launcher.daemon.registry.PersistentDaemonRegistry] Removing daemon address: [some-address port:35450, addresses:[/0:0:0:0:0:0:0:1%lo, /127.0.0.1]]
21:57:53.529 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Waiting to acquire exclusive lock on daemon addresses registry.
21:57:53.529 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Lock acquired on daemon addresses registry.
21:57:53.530 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Releasing lock on daemon addresses registry.
21:57:53.530 [DEBUG] [org.gradle.process.internal.ExecHandleRunner] Abort requested. Destroying process: command '/path/to/jsvc'.
21:57:53.532 [DEBUG] [org.gradle.process.internal.DefaultExecHandle] Changing state to: ABORTED
21:57:53.533 [DEBUG] [org.gradle.process.internal.DefaultExecHandle] Process 'command '/path/to/jsvc'' finished with exit value 1 (state: ABORTED)
----- End of the daemon log -----
21:57:53.888 [DEBUG] [org.gradle.launcher.daemon.client.DaemonClientInputForwarder] Dispatching close input message: org.gradle.launcher.daemon.protocol.CloseInput@ce9a99
21:57:53.888 [DEBUG] [org.gradle.launcher.daemon.client.DaemonClientConnection] thread 18: dispatching class org.gradle.launcher.daemon.protocol.CloseInput
21:57:53.889 [DEBUG] [org.gradle.launcher.daemon.client.DaemonClientConnection] thread 1: connection stop
21:57:53.907 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]
21:57:53.907 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] FAILURE: Build failed with an exception.
21:57:53.907 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]
21:57:53.908 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] * What went wrong:
21:57:53.908 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] Gradle build daemon disappeared unexpectedly (it may have been killed or may have crashed)
21:57:53.908 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]
21:57:53.908 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] * Try:
21:57:53.908 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] Run with --stacktrace option to get the stack trace.
任何帮助将不胜感激:)
我只需要指定文件描述符符号链接的完整路径(即 /proc/self/fd/1
用于 stdout
和 /proc/self/fd/2
用于 stderr
),现在正在完成输出安慰。
Gradle 守护进程仍然崩溃,但我认为这是由于 Gradle 无法处理 jsvc 守护进程自行终止(?)。