简体   繁体   English

Hudson 作业挂在 Runtime.exec

[英]Hudson job hangs at Runtime.exec

I'm running Hudson as a windows service through Tomcat, with no slaves involved.我通过 Tomcat 将 Hudson 作为 Windows 服务运行,不涉及从属设备。 The last build step in the job is a batch file that invokes some Java code.作业中的最后一个构建步骤是一个调用一些 Java 代码的批处理文件。 The code uses PostgreSQL's command line tool psql (via Runtime.exec()) to create a database on the local machine and eventually run some tests against it.该代码使用 PostgreSQL 的命令行工具 psql(通过 Runtime.exec())在本地机器上创建一个数据库,并最终对其运行一些测试。

The job will progress to this point, then hang indefinitely without starting to create the database.作业将进行到这一点,然后无限期挂起而不开始创建数据库。 If I run the batch file from the command line, it works perfectly.如果我从命令行运行批处理文件,它可以完美运行。 I don't think http://hudson.gotdns.com/wiki/display/HUDSON/Spawning+processes+from+build applies, since the process spawned doesn't even seem to begin executing, but I'm new to this so please let me know if I'm wrong.我认为http://hudson.gotdns.com/wiki/display/HUDSON/Spawning+processes+from+build 不适用,因为产生的进程似乎还没有开始执行,但我对此很陌生所以如果我错了,请告诉我。

Edit @anjanb: The batch file's only purpose is to invoke the Java code, and the only user input is being passed in as command line arguments, which I can see are going in directly via the build's console output.编辑@anjanb:批处理文件的唯一目的是调用 Java 代码,唯一的用户输入是作为命令行参数传入的,我可以看到直接通过构建的控制台输出输入。

Process Explorer is showing that psql is being started, but it's obviously not being executed, since the first command psql is given is to create a new database, but that's not happening. Process Explorer 显示 psql 正在启动,但它显然没有被执行,因为给出的第一个命令 psql 是创建一个新数据库,但这并没有发生。

Edit 2: I've gotten some tips from the Hudson users mailing list, I'll try them out on Monday and report back.编辑 2:我从 Hudson 用户邮件列表中获得了一些提示,我将在周一试用并报告。

Edit 3: The Java code was already consuming the output streams, I used that article when developing the code.编辑 3:Java 代码已经在使用输出流,我在开发代码时使用了那篇文章。 I can't figure out what's going on, so I'm redeveloping the code to use JDBC to create the database, instead of relying on psql and Runtime.exec()我想不通是怎么回事,所以我正在重新开发代码以使用 JDBC 创建数据库,而不是依赖 psql 和 Runtime.exec()

Do you read the output of the process ?你读过这个过程的输出吗? If it produces more output than the OS buffers can handle, you need to read it...如果它产生的输出比操作系统缓冲区可以处理的多,则需要读取它...

Also, some processes wait until input has completed.此外,某些进程会等待输入完成。 Try to call process.getInputStream().close() after starting the process.尝试在启动进程后调用 process.getInputStream().close() 。

Maybe this article is also interesting.也许这篇文章也很有趣。 It's called "When Runtime.exec() won't": http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html?page=2它被称为“当 Runtime.exec() 不会时”: http : //www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html? page =2

There is a possibility that the program is waiting on some user input.程序可能正在等待某些用户输入。 If the service is not configured to accept user input, it will appear to be hanging.如果该服务未配置为接受用户输入,它将显示为挂起。

YOu can try by configuring the service to allow USER INPUT(GUI) -- that might help.您可以尝试将服务配置为允许 USER INPUT(GUI)——这可能会有所帮助。

Also, you could run Sysinternals ProcessExplorer and ProcessMonitor -- they will be able to find out where the .BAT job has stopped.此外,您可以运行 Sysinternals ProcessExplorer 和 ProcessMonitor——它们将能够找出 .BAT 作业停止的位置。

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

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