【问题标题】:How do you deploy Mojolicious applications onto production servers?您如何将 Mojolicious 应用程序部署到生产服务器上?
【发布时间】:2013-04-09 08:07:30
【问题描述】:

我一直在开发我的第一个 Mojolicious 应用程序。直到现在我一直从开发目录运行它,但现在我想安装在生产服务器上。 mojo generate app 生成了我用来存储模板和静态文件的目录 templates/ 和 public/。我使用 Dist::Zilla 创建了一个简单的发行版,但在运行时我无法访问 templates/ 和 public/。

我提供的解决方案是将templates/和public/移动到一个新的目录share/中,然后让File::ShareDir(或Dist::Zilla的ShareDir插件)把它捡起来,这样我就可以配置合适的了我的 *_mode 方法中的路径:

sub development_mode{
    my $app = shift;
    push @{$app->static->paths}, rel2abs(catdir('share', 'public') );
    push @{$app->renderer->paths}, rel2abs(catdir('share', 'templates') );
}

sub production_mode{
    my $app = shift;
    push @{$app->static->paths}, catdir(dist_dir('FooBar'), 'public') ;
    push @{$app->renderer->paths}, catdir(dist_dir('FooBar'), 'templates') ;
}

有没有更正式的方式来做到这一点?

【问题讨论】:

    标签: perl mojolicious


    【解决方案1】:

    不,我就是这样做的,Galileo 和我为你做这件事的更通用的插件:Mojolicious::Plugin::InstallablePaths

    【讨论】:

      猜你喜欢
      • 2013-11-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-04-29
      • 2016-08-04
      相关资源
      最近更新 更多