From c9c66cf4207bd83e7760d01594d855f8254093d9 Mon Sep 17 00:00:00 2001 From: Julian Maurice Date: Thu, 8 Oct 2020 08:39:16 +0200 Subject: [PATCH] Bug 26625: (alternative) Use Config plugin in Mojolicious apps This allows to have separate config files for each mojolicious app. They can also both use the same config file. The config file is Perl code, so the configuration can be dynamic See https://docs.mojolicious.org/Mojolicious/Plugin/Config --- Koha/App/Intranet.pm | 4 ++++ Koha/App/Opac.pm | 4 ++++ etc/koha-mojolicious.conf | 9 +++++++++ 3 files changed, 17 insertions(+) create mode 100644 etc/koha-mojolicious.conf diff --git a/Koha/App/Intranet.pm b/Koha/App/Intranet.pm index bf66e9e62b..2595d576ef 100644 --- a/Koha/App/Intranet.pm +++ b/Koha/App/Intranet.pm @@ -27,6 +27,10 @@ use Koha::Cache::Memory::Lite; sub startup { my ($self) = @_; + # Setting a default config to avoid errors if the config file is missing + # Set MOJO_CONFIG environment variable to define the config file path + $self->plugin('Config', { default => {} }); + push @{$self->plugins->namespaces}, 'Koha::App::Plugin'; push @{$self->static->paths}, $self->home->rel_file('koha-tmpl'); diff --git a/Koha/App/Opac.pm b/Koha/App/Opac.pm index 7af85e1515..54b04203ca 100644 --- a/Koha/App/Opac.pm +++ b/Koha/App/Opac.pm @@ -27,6 +27,10 @@ use Koha::Cache::Memory::Lite; sub startup { my ($self) = @_; + # Setting a default config to avoid errors if the config file is missing + # Set MOJO_CONFIG environment variable to define the config file path + $self->plugin('Config', { default => {} }); + push @{$self->plugins->namespaces}, 'Koha::App::Plugin'; push @{$self->static->paths}, $self->home->rel_file('koha-tmpl'); diff --git a/etc/koha-mojolicious.conf b/etc/koha-mojolicious.conf new file mode 100644 index 0000000000..b66f032e4d --- /dev/null +++ b/etc/koha-mojolicious.conf @@ -0,0 +1,9 @@ +# Example of config file for mojolicious applications +# https://docs.mojolicious.org/Mojolicious/Plugin/Config +{ + # Hypnotoad settings + # https://metacpan.org/pod/Mojo::Server::Hypnotoad#SETTINGS + hypnotoad => { + listen => ['http://*:8000'], + }, +} -- 2.20.1