Entry tags:
(no subject)
Я поторопился стереть пост про PHP на радостях, что все будто бы заработало, а оно нет.
Ситуация такая: попросили сделать интеграцию между BeanStalk и Mantis. Mantis бежит на удаленном сервере. К нему приходит пост-реквест с мессагой от Subversion, у него php-скрипт, который ее парсит и с параметрами вызывает другой скрипт. Когда мантис бежал на винде в нашей локалке, команда вызова этого скрипта была такой:
shell_exec("echo -n \"$message\" | C:\php\php.exe checkin.php $author 2>&1");
и работала. Потом мантис переехал на юникс-сервер. Я написал:
shell_exec("echo -n \"$message\" | /usr/bin/php ./checkin.php $author 2>&1");
и приготовился радоваться, ан шиш. Мне то говорится "sh: fork: retry: Resource temporarily unavailable", что объяснимо, хотя и непонятно, как преодолевать (не хочется переписывать мантисовский хозяйский скрипт, хер их знает, для чего еще он у них используется. То, если вдруг прорвется дальше, возникает следующая проблема: в том скрипте, который вызывается, есть проверка:
# Make sure this script doesn't run via the webserver
if( php_sapi_name() != 'cli' ) {
echo "checkin.php is not allowed to run through the webserver.\n";
exit( 1 );
}
и по ней он вылетает. Интересно, как же оно работало на винде, точно такие же запросы ведь получало. На PHP я никогда ничего не писал, тонкостей не понимаю.
Кстати, вообще довольно странная картина. Весь приемный скрипт, которому посылается реквест, выглядит так:
<?php
ini_set('display_errors', 'On');
error_reporting(E_ALL | E_STRICT);
date_default_timezone_set('UTC');
$json = rawurldecode(file_get_contents('php://input'));
$data = json_decode($json);
$author = $data->{'author'};
$message = $data->{'message'};
echo("Author: $author; Message: $message\n");
$output = shell_exec("echo -n \"$message\" | /usr/bin/php ./checkin.php $author 2>&1");
echo(date('Y-m-d H:i:s') . " checkin.php: $output\n");
?>
(Кое-что выкинуто, но суть такова)
Результат его вызова выглядит так:
2013-04-08 08:34:31 post-commit.php:
received JSON: {
"time": "2013/04/07 14:49:48 +0300",
"message": "Testing Integration, issue #3126",
"author_full_name": "Lev Shenderovich",
"author_email": "lev@viewbix.com",
"changed_dirs": [],
"changeset_url": "http://наш svn-сервер/репозиторий/changesets/2698",
"changed_files": [["branches/20130227_Admin/delete.me",
"add"]],
"author": "lev",
"revision": 2698
}
Author: lev; Message: Testing Integration, issue #3126
2013-04-08 08:34:54 checkin.php: Content-type: text/html
2013-04-08 08:34:31 post-commit.php:
received JSON: Testing Integration, issue #3126
Notice: Trying to get property of non-object in /home/viewbix/public_html/bugs/scripts/post-commit.php on line 16
Notice: Trying to get property of non-object in /home/viewbix/public_html/bugs/scripts/post-commit.php on line 17
Author: ; Message:
2013-04-08 08:34:54 checkin.php: Content-type: text/html
2013-04-08 08:34:31 post-commit.php:
received JSON:
Notice: Trying to get property of non-object in /home/viewbix/public_html/bugs/scripts/post-commit.php on line 16
Notice: Trying to get property of non-object in /home/viewbix/public_html/bugs/scripts/post-commit.php on line 17
Author: ; Message:
2013-04-08 08:34:54 checkin.php: Content-type: text/html
2013-04-08 08:34:31 post-commit.php:
received JSON:
Notice: Trying to get property of non-object in /home/viewbix/public_html/bugs/scripts/post-commit.php on line 16
Notice: Trying to get property of non-object in /home/viewbix/public_html/bugs/scripts/post-commit.php on line 17
Author: ; Message:
2013-04-08 08:34:54 checkin.php: Content-type: text/html
2013-04-08 08:34:31 post-commit.php:
received JSON:
Notice: Trying to get property of non-object in /home/viewbix/public_html/bugs/scripts/post-commit.php on line 16
Notice: Trying to get property of non-object in /home/viewbix/public_html/bugs/scripts/post-commit.php on line 17
Author: ; Message:
2013-04-08 08:34:54 checkin.php: Content-type: text/html
2013-04-08 08:34:32 post-commit.php:
received JSON:
Notice: Trying to get property of non-object in /home/viewbix/public_html/bugs/scripts/post-commit.php on line 16
Notice: Trying to get property of non-object in /home/viewbix/public_html/bugs/scripts/post-commit.php on line 17
Author: ; Message:
2013-04-08 08:34:54 checkin.php: Content-type: text/html
2013-04-08 08:34:32 post-commit.php:
received JSON:
Notice: Trying to get property of non-object in /home/viewbix/public_html/bugs/scripts/post-commit.php on line 16
Notice: Trying to get property of non-object in /home/viewbix/public_html/bugs/scripts/post-commit.php on line 17
Author: ; Message:
2013-04-08 08:34:54 checkin.php: Content-type: text/html
2013-04-08 08:34:32 post-commit.php:
received JSON:
Notice: Trying to get property of non-object in /home/viewbix/public_html/bugs/scripts/post-commit.php on line 16
Notice: Trying to get property of non-object in /home/viewbix/public_html/bugs/scripts/post-commit.php on line 17
Author: ; Message:
2013-04-08 08:34:54 checkin.php: Content-type: text/html
2013-04-08 08:34:32 post-commit.php:
received JSON:
Notice: Trying to get property of non-object in /home/viewbix/public_html/bugs/scripts/post-commit.php on line 16
Notice: Trying to get property of non-object in /home/viewbix/public_html/bugs/scripts/post-commit.php on line 17
Author: ; Message:
2013-04-08 08:34:54 checkin.php: Content-type: text/html
2013-04-08 08:34:32 post-commit.php:
received JSON:
Notice: Trying to get property of non-object in /home/viewbix/public_html/bugs/scripts/post-commit.php on line 16
Notice: Trying to get property of non-object in /home/viewbix/public_html/bugs/scripts/post-commit.php on line 17
Author: ; Message:
2013-04-08 08:34:54 checkin.php: Content-type: text/html
2013-04-08 08:34:32 post-commit.php:
received JSON:
Notice: Trying to get property of non-object in /home/viewbix/public_html/bugs/scripts/post-commit.php on line 16
Notice: Trying to get property of non-object in /home/viewbix/public_html/bugs/scripts/post-commit.php on line 17
Author: ; Message:
2013-04-08 08:34:54 checkin.php: Content-type: text/html
2013-04-08 08:34:32 post-commit.php:
received JSON:
Notice: Trying to get property of non-object in /home/viewbix/public_html/bugs/scripts/post-commit.php on line 16
Notice: Trying to get property of non-object in /home/viewbix/public_html/bugs/scripts/post-commit.php on line 17
Author: ; Message:
sh: fork: retry: Resource temporarily unavailable
sh: fork: retry: Resource temporarily unavailable
sh: fork: retry: Resource temporarily unavailable
sh: fork: retry: Resource temporarily unavailable
sh: fork: retry: Resource temporarily unavailable
sh: fork: retry: Resource temporarily unavailable
sh: fork: retry: Resource temporarily unavailable
sh: fork: Resource temporarily unavailable
2013-04-08 08:34:54 checkin.php:
Что за трудновыразимая херня происходит у меня со вводом-выводом?
Вопрос не очень срочный, поскольку задачу эту отложили. Как пойму, в чем дело, так и починю.
Ситуация такая: попросили сделать интеграцию между BeanStalk и Mantis. Mantis бежит на удаленном сервере. К нему приходит пост-реквест с мессагой от Subversion, у него php-скрипт, который ее парсит и с параметрами вызывает другой скрипт. Когда мантис бежал на винде в нашей локалке, команда вызова этого скрипта была такой:
shell_exec("echo -n \"$message\" | C:\php\php.exe checkin.php $author 2>&1");
и работала. Потом мантис переехал на юникс-сервер. Я написал:
shell_exec("echo -n \"$message\" | /usr/bin/php ./checkin.php $author 2>&1");
и приготовился радоваться, ан шиш. Мне то говорится "sh: fork: retry: Resource temporarily unavailable", что объяснимо, хотя и непонятно, как преодолевать (не хочется переписывать мантисовский хозяйский скрипт, хер их знает, для чего еще он у них используется. То, если вдруг прорвется дальше, возникает следующая проблема: в том скрипте, который вызывается, есть проверка:
# Make sure this script doesn't run via the webserver
if( php_sapi_name() != 'cli' ) {
echo "checkin.php is not allowed to run through the webserver.\n";
exit( 1 );
}
и по ней он вылетает. Интересно, как же оно работало на винде, точно такие же запросы ведь получало. На PHP я никогда ничего не писал, тонкостей не понимаю.
Кстати, вообще довольно странная картина. Весь приемный скрипт, которому посылается реквест, выглядит так:
<?php
ini_set('display_errors', 'On');
error_reporting(E_ALL | E_STRICT);
date_default_timezone_set('UTC');
$json = rawurldecode(file_get_contents('php://input'));
$data = json_decode($json);
$author = $data->{'author'};
$message = $data->{'message'};
echo("Author: $author; Message: $message\n");
$output = shell_exec("echo -n \"$message\" | /usr/bin/php ./checkin.php $author 2>&1");
echo(date('Y-m-d H:i:s') . " checkin.php: $output\n");
?>
(Кое-что выкинуто, но суть такова)
Результат его вызова выглядит так:
2013-04-08 08:34:31 post-commit.php:
received JSON: {
"time": "2013/04/07 14:49:48 +0300",
"message": "Testing Integration, issue #3126",
"author_full_name": "Lev Shenderovich",
"author_email": "lev@viewbix.com",
"changed_dirs": [],
"changeset_url": "http://наш svn-сервер/репозиторий/changesets/2698",
"changed_files": [["branches/20130227_Admin/delete.me",
"add"]],
"author": "lev",
"revision": 2698
}
Author: lev; Message: Testing Integration, issue #3126
2013-04-08 08:34:54 checkin.php: Content-type: text/html
2013-04-08 08:34:31 post-commit.php:
received JSON: Testing Integration, issue #3126
Notice: Trying to get property of non-object in /home/viewbix/public_html/bugs/scripts/post-commit.php on line 16
Notice: Trying to get property of non-object in /home/viewbix/public_html/bugs/scripts/post-commit.php on line 17
Author: ; Message:
2013-04-08 08:34:54 checkin.php: Content-type: text/html
2013-04-08 08:34:31 post-commit.php:
received JSON:
Notice: Trying to get property of non-object in /home/viewbix/public_html/bugs/scripts/post-commit.php on line 16
Notice: Trying to get property of non-object in /home/viewbix/public_html/bugs/scripts/post-commit.php on line 17
Author: ; Message:
2013-04-08 08:34:54 checkin.php: Content-type: text/html
2013-04-08 08:34:31 post-commit.php:
received JSON:
Notice: Trying to get property of non-object in /home/viewbix/public_html/bugs/scripts/post-commit.php on line 16
Notice: Trying to get property of non-object in /home/viewbix/public_html/bugs/scripts/post-commit.php on line 17
Author: ; Message:
2013-04-08 08:34:54 checkin.php: Content-type: text/html
2013-04-08 08:34:31 post-commit.php:
received JSON:
Notice: Trying to get property of non-object in /home/viewbix/public_html/bugs/scripts/post-commit.php on line 16
Notice: Trying to get property of non-object in /home/viewbix/public_html/bugs/scripts/post-commit.php on line 17
Author: ; Message:
2013-04-08 08:34:54 checkin.php: Content-type: text/html
2013-04-08 08:34:32 post-commit.php:
received JSON:
Notice: Trying to get property of non-object in /home/viewbix/public_html/bugs/scripts/post-commit.php on line 16
Notice: Trying to get property of non-object in /home/viewbix/public_html/bugs/scripts/post-commit.php on line 17
Author: ; Message:
2013-04-08 08:34:54 checkin.php: Content-type: text/html
2013-04-08 08:34:32 post-commit.php:
received JSON:
Notice: Trying to get property of non-object in /home/viewbix/public_html/bugs/scripts/post-commit.php on line 16
Notice: Trying to get property of non-object in /home/viewbix/public_html/bugs/scripts/post-commit.php on line 17
Author: ; Message:
2013-04-08 08:34:54 checkin.php: Content-type: text/html
2013-04-08 08:34:32 post-commit.php:
received JSON:
Notice: Trying to get property of non-object in /home/viewbix/public_html/bugs/scripts/post-commit.php on line 16
Notice: Trying to get property of non-object in /home/viewbix/public_html/bugs/scripts/post-commit.php on line 17
Author: ; Message:
2013-04-08 08:34:54 checkin.php: Content-type: text/html
2013-04-08 08:34:32 post-commit.php:
received JSON:
Notice: Trying to get property of non-object in /home/viewbix/public_html/bugs/scripts/post-commit.php on line 16
Notice: Trying to get property of non-object in /home/viewbix/public_html/bugs/scripts/post-commit.php on line 17
Author: ; Message:
2013-04-08 08:34:54 checkin.php: Content-type: text/html
2013-04-08 08:34:32 post-commit.php:
received JSON:
Notice: Trying to get property of non-object in /home/viewbix/public_html/bugs/scripts/post-commit.php on line 16
Notice: Trying to get property of non-object in /home/viewbix/public_html/bugs/scripts/post-commit.php on line 17
Author: ; Message:
2013-04-08 08:34:54 checkin.php: Content-type: text/html
2013-04-08 08:34:32 post-commit.php:
received JSON:
Notice: Trying to get property of non-object in /home/viewbix/public_html/bugs/scripts/post-commit.php on line 16
Notice: Trying to get property of non-object in /home/viewbix/public_html/bugs/scripts/post-commit.php on line 17
Author: ; Message:
2013-04-08 08:34:54 checkin.php: Content-type: text/html
2013-04-08 08:34:32 post-commit.php:
received JSON:
Notice: Trying to get property of non-object in /home/viewbix/public_html/bugs/scripts/post-commit.php on line 16
Notice: Trying to get property of non-object in /home/viewbix/public_html/bugs/scripts/post-commit.php on line 17
Author: ; Message:
sh: fork: retry: Resource temporarily unavailable
sh: fork: retry: Resource temporarily unavailable
sh: fork: retry: Resource temporarily unavailable
sh: fork: retry: Resource temporarily unavailable
sh: fork: retry: Resource temporarily unavailable
sh: fork: retry: Resource temporarily unavailable
sh: fork: retry: Resource temporarily unavailable
sh: fork: Resource temporarily unavailable
2013-04-08 08:34:54 checkin.php:
Что за трудновыразимая херня происходит у меня со вводом-выводом?
Вопрос не очень срочный, поскольку задачу эту отложили. Как пойму, в чем дело, так и починю.