perl – 为什么我在Heroku上使用hypnotoad崩溃?

前端之家收集整理的这篇文章主要介绍了perl – 为什么我在Heroku上使用hypnotoad崩溃?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我试图用0700应用程序在 HerokuPerloku上运行催眠器.当 hypnotoad进入其运行循环导致它崩溃时,会发生一些事情.我想我错过了一些简单的东西,但Heroku文档没有帮助,我无法从中哄骗好的错误信息.

我从一个非常简单的应用程序开始,所以显示一些环境变量

#!/usr/bin/env perl
# today
use MojolicIoUs::Lite;

get '/' => sub {
    my $c = shift;

    my $content = "Perl: $^X Pid: $$\n\n";
    foreach my $key ( keys %ENV ) {
        next unless $key =~ /Mojo|toad/i;
        $content .= "$key $ENV{$key}\n";
        }

    $c->stash( content => $content );

    $c->render('index');
    };

app->start;

__DATA__

@@ index.html.ep
% layout 'default';
% title 'Welcome';
<p>Welcome to the MojolicIoUs real-time web framework!</p>

<pre>
<%= $content %>
</pre>

@@ layouts/default.html.ep
<!DOCTYPE html>
<html>
  <head><title><%= title %></title></head>
  <body><%= content %></body>
</html>

当我在本地运行时,我没有问题.我从环境变量中看到我的程序是在hypnotoad下运行的:

Welcome to the MojolicIoUs real-time web framework!

Perl: /Users/brian/DropBox/bin/perls/perl5.20.0 Pid: 40006

HYPNOTOAD_PID 39981
MOJO_HELP 
HYPNOTOAD_TEST 
HYPNOTOAD_EXE /Users/brian/bin/perls/hypnotoad5.20.0
MOJO_REUSE 0.0.0.0:8080:6
HYPNOTOAD_REV 3
HYPNOTOAD_APP /Users/brian/Desktop/toady.d/toady
MOJO_MODE production
MOJO_HOME
HYPNOTOAD_STOP 
HYPNOTOAD_FOREGROUND

现在,我用Mojolicious::Command::deploy::heroku部署它:

% toady deploy heroku --create

这是在https://frozen-brushlands-4002.herokuapp.com运行,使用默认的Perloku文件

#!/bin/sh
./toady daemon --listen http://*:$PORT --mode production

尽管有一些参考文献我已经看到过这就是我应该得到的东西,但这并没有运行催眠术.该应用程序可行:

Welcome to the MojolicIoUs real-time web framework!

Perl: /app/vendor/perl/bin/perl Pid: 3

MOJO_REUSE 0.0.0.0:12270:4
MOJO_HOME 
MOJO_HELP 
MOJO_MODE production
MOJO_EXE ./toady

我想我可以更改Perloku文件以启动hypnotoad:

#!/bin/sh
/app/vendor/perl/bin/perl /app/vendor/perl-deps/bin/hypnotoad toady

hypnotoad启动并几乎立即关闭,没有其他日志消息:

% heroku logs --app ...
2015-01-04T09:23:36.516864+00:00 heroku[web.1]: Starting process with command `./Perloku`
2015-01-04T09:23:38.321628+00:00 heroku[web.1]: State changed from starting to crashed

我可以更改调用以使用-t来测试应用程序以查看是否:

#!/bin/sh
/app/vendor/perl/bin/perl /app/vendor/perl-deps/bin/hypnotoad -t toady

这有效,我得到“一切看起来都很棒!”消息,所以催眠运行正在运行:

2015-01-04T09:36:36.955680+00:00 heroku[web.1]: Starting process with command `./Perloku`
2015-01-04T09:36:38.340717+00:00 app[web.1]: Everything looks good!
2015-01-04T09:36:39.085887+00:00 heroku[web.1]: State changed from starting to crashed

我打开Mojo调试日志记录,但除了我自己的语句之外,我没有看到其他输出.

#!/usr/bin/env perl
use MojolicIoUs::Lite;

$|++;

my $log = app->log;

$log->level( 'debug' );

$log->debug( "INC: @INC" );

get '/' => sub {
    ...;
    };

$log->debug( "Right before start" );
my $app = app->start;
$log->debug( "Right after start" );

$app; # must return application object

我尝试了其他的东西,比如让它加载一个我知道不存在的模块,并且我在日志中得到了预期的“找不到”错误.

从heroku(heroku run bash)中的shell运行并不是很有启发性. mojo版本的输出与我本地机器上的输出相同:

$perl vendor/perl-deps/bin/mojo version
CORE
  Perl        (v5.16.2,linux)
  MojolicIoUs (5.71,Tiger Face)

OPTIONAL
  EV 4.0+                 (n/a)
  IO::Socket::Socks 0.64+ (n/a)
  IO::Socket::SSL 1.84+   (n/a)
  Net::DNS::Native 0.15+  (n/a)

You might want to update your MojolicIoUs to 5.72.

我认为有一些非常简单的东西我不知道,但与此同时,这些都不是为了便于调试而构建的.

Oleg离得更近了,但仍有问题.我之前尝试过前台选项并遇到同样的问题,但没有提到它.

如果我在前台启动hypnotoad,它会尝试绑定到一个地址.它无法绑定到端口80(或443)并崩溃,并且它可以监听127.0.0.1:几乎,但看起来它无法完全侦听:

2015-01-13T11:47:54+00:00 heroku[slug-compiler]: Slug compilation started
2015-01-13T11:48:32+00:00 heroku[slug-compiler]: Slug compilation finished
2015-01-13T11:48:32.735095+00:
00 heroku[api]: Deploy dcab778 by ...
2015-01-13T11:48:32.735095+00:00 heroku[api]: Release v31 created by ...
2015-01-13T11:48:32.969489+00:00 heroku[web.1]: State changed from crashed to starting
2015-01-13T11:48:34.909134+00:00 heroku[web.1]: Starting process with command `./Perloku`
2015-01-13T11:48:36.045985+00:00 app[web.1]: Can't create listen socket: Permission denied at /app/vendor/perl-deps/lib/perl5/Mojo/IOLoop.pm line 120.
2015-01-13T11:48:36.920004+00:00 heroku[web.1]: Process exited with status 13
2015-01-13T11:48:36.932014+00:00 heroku[web.1]: State changed from starting to crashed

这是一个无特权的端口:

2015-01-13T11:39:10+00:00 heroku[slug-compiler]: Slug compilation started
2015-01-13T11:39:44+00:00 heroku[slug-compiler]: Slug compilation finished
2015-01-13T11:39:44.519679+00:00 heroku[api]: Deploy bbd1f68 by ...
2015-01-13T11:39:44.519679+00:00 heroku[api]: Release v29 created by ...
2015-01-13T11:39:44.811111+00:00 heroku[web.1]: State changed from crashed to starting
2015-01-13T11:39:47.382298+00:00 heroku[web.1]: Starting process with command `./Perloku`
2015-01-13T11:39:48.454706+00:00 app[web.1]: [Tue Jan 13 11:39:48 2015] [info] Listening at "http://*:8000".
2015-01-13T11:39:48.454733+00:00 app[web.1]: Server available at http://127.0.0.1:8000.
2015-01-13T11:39:48.454803+00:00 app[web.1]: [Tue Jan 13 11:39:48 2015] [info] Manager 3 started.
2015-01-13T11:39:48.480084+00:00 app[web.1]: [Tue Jan 13 11:39:48 2015] [info] Creating process id file "/app/hypnotoad.pid".
2015-01-13T11:40:47.703110+00:00 heroku[web.1]: Stopping process with SIGKILL
2015-01-13T11:40:47.702867+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process Failed to bind to $PORT within 60 seconds of launch
2015-01-13T11:40:48.524470+00:00 heroku[web.1]: Process exited with status 137
2015-01-13T11:40:48.534002+00:00 heroku[web.1]: State changed from starting to crashed

解决方法

这真是一个疯狂的猜测,但也许heroku基础设施不期望跑步者终止?如果是这样,您可以尝试使用–foreground或-f启动hypnotoad.

此外,您可以尝试从应用程序内部进行一些日志记录,以查看它是否曾经运行过它.

原文链接:https://www.f2er.com/Perl/171861.html

猜你在找的Perl相关文章