Perl脚本在Tomcat 6.0上运行缓慢,并产生服务超时 [英] Perl Script slow over tom cat 6.0 and generates service time out

查看:223
本文介绍了Perl脚本在Tomcat 6.0上运行缓慢,并产生服务超时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Windows 2008 R2上运行Tomcat 6.0服务器上的perl脚本以从存储库中提取。该脚本变得非常缓慢,因为它必须等待git pull完成。这为Github webhook创建了一个服务超时,它实际上触发了脚本。除了下面的代码外,代码中没有任何内容。

  exec(C:\\Git\\\\\ bin\\git.exe pull); 

如何改进脚本以便webhook开始工作。以下是我在github webhook上得到的错误。


我们无法提供此有效内容:服务超时

当我在浏览器中运行脚本时,大约需要50秒到1分多钟。可能是tom猫超载了?

----使用fork之后更新-----
我使用下面的代码通过fork实现它。它在本地工作(当在命令行上执行时),但是当我通过web服务器运行时,我得到一个积极的信号给webhook,但没有提交更改意味着server_script没有运行。

  $ pid = fork(); 
if($ pid == 0){
exec(perl server_script.pl);
打印这是子进程。
打印子进程已存在\\\
;
exit 0;
}
print这是父进程,子ID是$ pid\\\
;
print父进程已存在\\\
;
exit 0;


解决方案

应该可以将两个操作分开: / b>


  • 侦听webhook有效负载


    第一个侦听器应该简单地举起一个标志(比如触摸一个文件),以便发送信号



    第二个进程应该监视该标志,如果该标志被引发,则启动 git pull



    通过将这两个操作解耦,通过使它们异步,您可以始终完成webhook。


    I am running a perl script on tom cat 6.0 server over windows 2008 R2 to pull from repository. The script becomes very slow because it has to wait for the git pull to complete. This creates a service time out for Github webhook which is actually triggering the script. There is nothing in the code except the following line.

    exec("C:\\Git\\bin\\git.exe pull") ;
    

    How can I improve the script so that the webhook starts working. The following is the error I get at the github webhook.

    We couldn’t deliver this payload: Service Timeout

    When I run the script in browser it takes roughly 50s to more than 1 minute. Probably the tom cat is overloaded?

    ---- Update after using fork ----- I used the following code to implement it via fork. It works locally (when executed on command line) but when I run via web server I get a positive signal to webhook but the changes are not committed meaning the server_script did not run.

    $pid = fork();
    if( $pid == 0 ){
       exec("perl server_script.pl");
       print "This is child process\n";
       print "Child process is existing\n";
       exit 0;
    }
    print "This is parent process and child ID is $pid\n";
    print "Parent process is existing\n";
    exit 0;
    

    解决方案

    It should be possible to decouple the two operations:

    • listening to the webhook payload
    • launching the git pull

    The first listener should simply raise a flag (like for instance touch a file), in order to signal the reception of the webhook.

    The second process should monitor that flag, and if said flag is raised, launch the git pull.

    By decoupling the two operations, by making them asynchronous, you allow the webhook to always complete.

    这篇关于Perl脚本在Tomcat 6.0上运行缓慢,并产生服务超时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆