Perl Script slow over tom cat 6.0 and generates service time out

纵然是瞬间 提交于 2019-12-08 04:19:06

问题


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;

回答1:


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.



来源:https://stackoverflow.com/questions/23824600/perl-script-slow-over-tom-cat-6-0-and-generates-service-time-out

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!