【问题标题】:mojolicious need all the time out time for load a page on production with hypnotoadmojolicious 需要一直在使用 hypnotoad 加载生产页面
【发布时间】:2019-04-23 18:42:10
【问题描述】:

我的 Mojolicious 项目中有一个页面可以正确加载,但连接直到超时时间才完成。

我只在生产服务器上遇到了 hypnotoad 的问题。

我无法在开发中复制问题。

由于页面正在执行以及对外部服务的 api 请求,我一直在调查该问题。

最初我认为这是由于一些 Mojo::UserAgent 问题,我一直在尝试 Promise 和 IOLoop 的多种组合,并且任何人都在工作。

代码简化为:

sub show {
    my $s = shift;

    my $customer = Model::Customers->new();
    $customer->id( $s->session('id') );
    $customer->get();

    my $subscription = Model::Customers::Subscriptions->new();
    $subscription->id( $s->session('id') );
    $subscription->get();

    my $plan = Model::Plans->new();
    $plan->id( $subscription->idPlan );
    $plan->get;


    $s->stash(
        namePlan => $plan->name,
        monthDuration => $plan->monthDuration,
        amount => $plan->amount,
        end => $subscription->end,
        status => $subscription->status,
        signupDate => $customer->signupDate,
        endTrial => $customer->endTrial,
        diffTrial => $customer->diffTrial,
        trialDays => $customer->trialDays,
        startSubscription => $subscription->start,
        discount => $plan->discount,
        newsletter => $newsletter,
    );

    $s->render();

}

我不共享模板代码,因为没有必要。

页面和模板加载正确,但浏览器 chrome 会一直加载,直到超时。 (默认 15 秒)

【问题讨论】:

标签: perl mojolicious


【解决方案1】:

问题的原因是我使用了保留的隐藏字“状态”。

解决方案是更改 stash 和模板中的变量名称:

   $s->stash(
        namePlan => $plan->name,
        monthDuration => $plan->monthDuration,
        amount => $plan->amount,
        end => $subscription->end,

        subStatus => $subscription->status,

        signupDate => $customer->signupDate,
        endTrial => $customer->endTrial,
        diffTrial => $customer->diffTrial,
        trialDays => $customer->trialDays,
        startSubscription => $subscription->start,
        discount => $plan->discount,
        newsletter => $newsletter,
    );

【讨论】:

猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-10-15
  • 1970-01-01
  • 2023-04-08
  • 2016-03-11
  • 1970-01-01
相关资源
最近更新 更多