mod_php vs context: tight loop
Hello list, I have a PHP application which generates documentation on the fly with context. This has been working really well, but I am now testing deployment on a new server with a more recent version of context, and it seems to be somehow getting itself into a tight loop. When I run texexec via the mod_php apache module, the command never returns, and `ps ax` shows the following: 9709 ? S 0:00 sh -c texexec --check 2>&1 9710 ? S 0:00 /bin/sh /usr/bin/texexec --check 9711 ? R 9:59 /usr/bin/texlua /usr/bin/mtxrun --usekpse --execute texexec --check `top` shows the mtxrun process eating 99.9% CPU. Attaching an strace to this process, once it is underway, shows no output. My test script is as follows: <?php $result = null; system("texexec --check 2>&1", $result); print $result . "\n"; ?> When this same test script is run directly from the command line with `php5 -f test.php`, it works as expected and outputs the following: MTXrun | kpse fallback with progname 'context' initialized in 0.01 secondsTeXExec | current distribution: web2c TeXExec | context source date: 2010.07.30 11:35 TeXExec | format path: . /root/.texmf-config/web2c/luatex /root/.texmf-var/web2c/luatex /root/texmf/web2c/luatex /etc/texmf/web2c/luatex /var/lib/texmf/web2c/luatex /usr/local/share/texmf/web2c/luatex /usr/share/texmf/web2c/luatex /usr/share/texmf-texlive/web2c/luatex /root/.texmf-config/web2c /root/.texmf-var/web2c /root/texmf/web2c /etc/texmf/web2c /var/lib/texmf/web2c /usr/local/share/texmf/web2c /usr/share/texmf/web2c /usr/share/texmf-texlive/web2c TeXExec | start of analysis TeXExec | end of analysis TeXExec | TeXExec | TeXExec | version 6.2.1 - 1997-2009 - PRAGMA ADE/POD 0 Using --timeout=30 in the arguments to texexec makes no difference; mtxrun nonetheless runs forever until it is signalled. It seems that this must be down to some kind of difference in Apache's execution environment -- I don't see any other way to explain the same PHP code working in cli and failing in mod_php, even when running as the same user. But what possible environmental factor could lead to mtxrun freaking out like this? I'm hoping someone on this list may be able to point me in the right direction. This server is a VZ instance running under proxmox, with the following relevant ubuntu packages installed (per the 'natty' release): context 2010.07.30-1 libapache2-mod-php5 5.3.5-1ubuntu7.3 apache2 2.2.17-1ubuntu1.4 -- Regards, Brendan Jurd Software Engineer Achieve, Corp brendan.jurd@achievecorp.com.au
On 25-11-2011 06:12, Brendan Jurd wrote:
Hello list,
I have a PHP application which generates documentation on the fly with context. This has been working really well, but I am now testing deployment on a new server with a more recent version of context, and it seems to be somehow getting itself into a tight loop.
When I run texexec via the mod_php apache module, the command never returns, and `ps ax` shows the following:
9709 ? S 0:00 sh -c texexec --check 2>&1 9710 ? S 0:00 /bin/sh /usr/bin/texexec --check 9711 ? R 9:59 /usr/bin/texlua /usr/bin/mtxrun --usekpse --execute texexec --check
`top` shows the mtxrun process eating 99.9% CPU. Attaching an strace to this process, once it is underway, shows no output.
My test script is as follows:
<?php $result = null; system("texexec --check 2>&1", $result); print $result . "\n"; ?>
When this same test script is run directly from the command line with `php5 -f test.php`, it works as expected and outputs the following:
MTXrun | kpse fallback with progname 'context' initialized in 0.01 secondsTeXExec | current distribution: web2c TeXExec | context source date: 2010.07.30 11:35 TeXExec | format path: . /root/.texmf-config/web2c/luatex /root/.texmf-var/web2c/luatex /root/texmf/web2c/luatex /etc/texmf/web2c/luatex /var/lib/texmf/web2c/luatex /usr/local/share/texmf/web2c/luatex /usr/share/texmf/web2c/luatex /usr/share/texmf-texlive/web2c/luatex /root/.texmf-config/web2c /root/.texmf-var/web2c /root/texmf/web2c /etc/texmf/web2c /var/lib/texmf/web2c /usr/local/share/texmf/web2c /usr/share/texmf/web2c /usr/share/texmf-texlive/web2c TeXExec | start of analysis TeXExec | end of analysis TeXExec | TeXExec | TeXExec | version 6.2.1 - 1997-2009 - PRAGMA ADE/POD
0
Using --timeout=30 in the arguments to texexec makes no difference; mtxrun nonetheless runs forever until it is signalled.
It seems that this must be down to some kind of difference in Apache's execution environment -- I don't see any other way to explain the same PHP code working in cli and failing in mod_php, even when running as the same user. But what possible environmental factor could lead to mtxrun freaking out like this? I'm hoping someone on this list may be able to point me in the right direction.
This server is a VZ instance running under proxmox, with the following relevant ubuntu packages installed (per the 'natty' release):
context 2010.07.30-1 libapache2-mod-php5 5.3.5-1ubuntu7.3 apache2 2.2.17-1ubuntu1.4
in such cases I always run with --batch to make sure that the job itself cannot block i have no clue Hans ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com | www.pragma-pod.nl -----------------------------------------------------------------
On 25/11/11 19:17, Hans Hagen wrote:
On 25-11-2011 06:12, Brendan Jurd wrote:
I have a PHP application which generates documentation on the fly with context. This has been working really well, but I am now testing deployment on a new server with a more recent version of context, and it seems to be somehow getting itself into a tight loop.
in such cases I always run with --batch to make sure that the job itself cannot block
Hi Hans, Thanks for the response. I tried running with --batch and it made no difference to the outcome. The mtxrun process still got jammed up in exactly the same manner. Regressing to the ubuntu 'lucid' packages resolved the problem for me, so whatever is wrong has gone wrong somewhere in the combination of packages in ubuntu 'natty'. -- Regards, Brendan Jurd Software Engineer Achieve, Corp brendan.jurd@achievecorp.com.au
Am 2011-11-27 um 06:45 schrieb Brendan Jurd:
On 25/11/11 19:17, Hans Hagen wrote:
On 25-11-2011 06:12, Brendan Jurd wrote:
I have a PHP application which generates documentation on the fly with context. This has been working really well, but I am now testing deployment on a new server with a more recent version of context, and it seems to be somehow getting itself into a tight loop.
Hi Brendan, I once had similar problems running ConTeXt (LuaTeX) behind my Django server (gunicorn or FCGI behind Nginx). In my case it was some strange permissions problem of the calling process. I could only avoid it by changing my process manager from daemontools to supervisord. Greetlings from Lake Constance! Hraban --- http://www.fiee.net/texnique/ http://wiki.contextgarden.net https://www.cacert.org (I'm an assurer)
On 27/11/11 16:45, Brendan Jurd wrote:
On 25/11/11 19:17, Hans Hagen wrote:
On 25-11-2011 06:12, Brendan Jurd wrote:
I have a PHP application which generates documentation on the fly with context. This has been working really well, but I am now testing deployment on a new server with a more recent version of context, and it seems to be somehow getting itself into a tight loop.
in such cases I always run with --batch to make sure that the job itself cannot block
Thanks for the response. I tried running with --batch and it made no difference to the outcome. The mtxrun process still got jammed up in exactly the same manner.
Regressing to the ubuntu 'lucid' packages resolved the problem for me, so whatever is wrong has gone wrong somewhere in the combination of packages in ubuntu 'natty'.
I did eventually get to the bottom of this. Turns out that mtxrun was failing to find a writable cache path (from mtxrun line 9269). To find a cache path, mtxrun searches through the environment variables TEXMFCACHE, TMPDIR, TEMPDIR, TMP, TEMP, HOME, HOMEPATH. The apache worker process had no such environment variables, so mtxrun failed. Once I added the following line to my PHP script, everything started working just fine: putenv('TEMPDIR=/tmp'); -- Regards, Brendan Jurd Software Engineer Achieve, Corp brendan.jurd@achievecorp.com.au
On 2-12-2011 02:59, Brendan Jurd wrote:
The apache worker process had no such environment variables, so mtxrun failed. Once I added the following line to my PHP script, everything started working just fine:
putenv('TEMPDIR=/tmp');
can you that on the wiki? maybe we need a section: "running context in webservices" or so ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com | www.pragma-pod.nl -----------------------------------------------------------------
On 02/12/11 21:31, Hans Hagen wrote:
On 2-12-2011 02:59, Brendan Jurd wrote:
The apache worker process had no such environment variables, so mtxrun failed. Once I added the following line to my PHP script, everything started working just fine:
putenv('TEMPDIR=/tmp');
can you that on the wiki? maybe we need a section: "running context in webservices" or so
I have added my findings to the wiki, as a new page. At the moment the page isn't linked to from anywhere else in the wiki. I wasn't sure which pages might have adjacent content. Please feel free to relocate this if you don't like the name, or think it doesn't deserve its own page. http://wiki.contextgarden.net/Running_ConTeXt_without_a_shell BTW, congratulations on the new theme for the wiki. It's a big improvement. -- Regards, Brendan Jurd Software Engineer Achieve, Corp brendan.jurd@achievecorp.com.au
participants (3)
-
Brendan Jurd
-
Hans Hagen
-
Henning Hraban Ramm