Mig Dancer 1 to 2: set confdir does not work?
Hello, I have created a webportal for my server installation and configuration functions with Dancer1. Now I want to add ldap user support and I think this is the opportunity to migrate to Dancer2. First I created a webapp with dancer2 gen -a "fsi" -p /opt/test/ After that I move the environment and config yml files to the etc dir and delete the environments dir. I want a clean root dir and so I move the rest of the files to the new doc dir. [root@fsisrv6 fsi]# pwd /opt/test/fsi [root@fsisrv6 fsi]# tree . ??? bin ? ??? app.psgi ??? doc ? ??? cpanfile ? ??? Makefile.PL ? ??? MANIFEST ? ??? MANIFEST.SKIP ??? etc ? ??? config.yml ? ??? development.yml ? ??? production.yml ??? lib ? ??? fsi.pm ??? public ? ??? 404.html ? ??? 500.html ? ??? css ? ? ??? error.css ? ? ??? style.css ? ??? dispatch.cgi ? ??? dispatch.fcgi ? ??? favicon.ico ? ??? images ? ? ??? perldancer-bg.jpg ? ? ??? perldancer.jpg ? ??? javascripts ? ??? jquery.js ??? t ? ??? 001_base.t ? ??? 002_index_route.t ??? views ??? index.tt ??? layouts ??? main.tt From my Dancer1 project, I copy the three set lines to the fsi.pm file: - - --- -- --- -- - ---- package fsi; use Dancer2; set confdir => "/opt/test/fsi/etc"; set envdir => "/opt/test/fsi/etc"; set environment => 'development'; our $VERSION = '0.1'; get '/' => sub { template 'index'; }; true; - - --- -- --- -- - ---- If I now start the portal with plackup -s Starman --workers=10 -a /opt/test/fsi/bin/app.psgi -p 3000 I see in the "Your application's environment" section: Location: /opt/test/fsi Template engine: <% settings.template %> Logger: <% settings.logger %> Environment: <% settings.environment %> So I think Dancer2 cannot find the config.yml file. I read that I must create a .dancer file in the etc dir: [root@fsisrv6 etc]# ls -lisa insgesamt 20 5376363 4 drwxr-xr-x 2 root root 4096 19. Mai 07:52 . 5376297 4 drwxr-xr-x 9 root root 4096 19. Mai 07:51 .. 5376359 4 -rw-r--r-- 1 root root 1414 19. Mai 07:52 config.yml 5376327 0 -rw-r--r-- 1 root root 0 19. Mai 07:49 .dancer 5376361 4 -rw-r--r-- 1 root root 727 19. Mai 07:49 development.yml 5376352 4 -rw-r--r-- 1 root root 302 19. Mai 07:49 production.yml But that does not work. What am I doing wrong? Who can help, please? Thank you & Regards Jochen PS: env infos: - CentOS 6 and 7 - Dancer2 0.166001
On May 24, 2016, at 3:03 AM, Jochen Schnuerle <js@betabox.de> wrote:
I want a clean root dir and so I move the rest of the files to the new doc dir.
Those aren’t documentation files, they’re build and packaging files. If you don’t want them, you can just remove them.
So I think Dancer2 cannot find the config.yml file.
You’re probably right.
I read that I must create a .dancer file in the etc dir:
Read where? I’ve never heard of that feature, and I can’t find it in the four most plausible Dancer2 documentation files. (Which was my point back when the subject of documentation came up last time: too many places to look!) Anyway, by grepping the sources, I found that this only appears once, in Dancer2/Core/Role/HasLocation.pm It is inside a loop that works by walking up the directory hierarchy, not down. That is, the .dancer trick would only work for a case like: project subdir/.dancer subsubdir …when you start your app from subsubdir, and it fails to find ‘bin’ or ‘lib’ in that directory. It goes up one level, finds the .dancer file, and assumes that is the root of the project, as far as Dancer is concerned. Your scheme doesn’t work because it is *below* the current working directory you run plackup within, not above it. (Incidentally, the comment above the line in question doesn’t match the action of the line it is commenting on!)
Warren,
I read that I must create a .dancer file in the etc dir: Read where?
an email from Russell: http://lists.preshweb.co.uk/pipermail/dancer-users/2015-December/005370.html But I don't unterstand.
It is inside a loop that works by walking up the directory hierarchy, not down. That is, the .dancer trick would only work for a case like:
project subdir/.dancer subsubdir
…when you start your app from subsubdir, and it fails to find ‘bin’ or ‘lib’ in that directory. It goes up one level, finds the .dancer file, and assumes that is the root of the project, as far as Dancer is concerned. Your scheme doesn’t work because it is *below* the current working directory you run plackup within, not above it.
In my Dancer1 source I have following lines: set confdir => "/opt/test/fsi/etc"; set envdir => "/opt/test/fsi/etc"; set environment => 'development'; I start searching in the Dancer2 source and found config_location and environments_location ... so I try: set config_location => '/opt/test/fsi/etc'; set environments_location => '/opt/test/fsi/etc'; set environment => 'development'; But I think I misunterstood this, because it doesn´t work. I just want to move my config.yml in the sub dir /etc. Regards Jochen
On May 24, 2016, at 7:50 AM, Jochen Schnuerle <js@betabox.de> wrote:
But I don't unterstand.
I pointed you right at the code implementing the feature you’re trying to use. It’s quite straightforward Perl. If you don’t understand my prose description of what it does, you should certainly understand the Perl code.
I just want to move my config.yml in the sub dir /etc.
The feature you’re trying to use doesn’t allow that. You will either have to structure your project directory differently, or change Dancer to behave the way you prefer.
On 05/24/2016 05:50 PM, Warren Young wrote:
On May 24, 2016, at 7:50 AM, Jochen Schnuerle <js@betabox.de> wrote:
But I don't unterstand.
I pointed you right at the code implementing the feature you’re trying to use. It’s quite straightforward Perl. If you don’t understand my prose description of what it does, you should certainly understand the Perl code.
I just want to move my config.yml in the sub dir /etc.
The feature you’re trying to use doesn’t allow that. You will either have to structure your project directory differently, or change Dancer to behave the way you prefer.
I suggest to look at the environment variables, which Dancer 2 uses: https://metacpan.org/pod/distribution/Dancer2/lib/Dancer2/Config.pod#Environ... Especially DANCER_CONFDIR and DANCER_ENVDIR. Regards Racke -- Please visit our 3rd Perl Dancer Conference 2016 in Vienna: https://www.perl.dance/.
Stefan, Stefan Hornburg (Racke) wrote:
On 05/24/2016 05:50 PM, Warren Young wrote:
On May 24, 2016, at 7:50 AM, Jochen Schnuerle<js@betabox.de> wrote:
But I don't unterstand. I pointed you right at the code implementing the feature you’re trying to use. It’s quite straightforward Perl. If you don’t understand my prose description of what it does, you should certainly understand the Perl code.
I just want to move my config.yml in the sub dir /etc. The feature you’re trying to use doesn’t allow that. You will either have to structure your project directory differently, or change Dancer to behave the way you prefer. I suggest to look at the environment variables, which Dancer 2 uses:
https://metacpan.org/pod/distribution/Dancer2/lib/Dancer2/Config.pod#Environ...
Especially DANCER_CONFDIR and DANCER_ENVDIR.
Regards Racke That worked great!
After configure the env vars: export DANCER_CONFDIR="/opt/fsi/portal/etc" export DANCER_ENVDIR="/opt/fsi/portal/etc" Dancer2 search for the "views" dir in /opt/fsi/portal/etc/views So I add to the config.yml of my Dancer2 source: views: "/opt/fsi/portal/views" and remove the source lines in my fsi.pm: #set config_location => $dirs . '../etc'; #set environments_location => $dirs . '../etc'; #set 'environment' => 'development'; and all works great, like I have it in my Dancer1 source/tree. Thank you very much! Regards Jochen
On 05/25/2016 09:49 AM, Jochen Schnuerle wrote:
Stefan,
Stefan Hornburg (Racke) wrote:
On 05/24/2016 05:50 PM, Warren Young wrote:
On May 24, 2016, at 7:50 AM, Jochen Schnuerle <js@betabox.de> wrote:
But I don't unterstand. I pointed you right at the code implementing the feature you’re trying to use. It’s quite straightforward Perl. If you don’t understand my prose description of what it does, you should certainly understand the Perl code.
I just want to move my config.yml in the sub dir /etc. The feature you’re trying to use doesn’t allow that. You will either have to structure your project directory differently, or change Dancer to behave the way you prefer. I suggest to look at the environment variables, which Dancer 2 uses:
https://metacpan.org/pod/distribution/Dancer2/lib/Dancer2/Config.pod#Environ...
Especially DANCER_CONFDIR and DANCER_ENVDIR.
Regards Racke That worked great!
After configure the env vars:
export DANCER_CONFDIR="/opt/fsi/portal/etc" export DANCER_ENVDIR="/opt/fsi/portal/etc"
Dancer2 search for the "views" dir in
/opt/fsi/portal/etc/views
So I add to the config.yml of my Dancer2 source:
views: "/opt/fsi/portal/views"
and remove the source lines in my fsi.pm:
#set config_location => $dirs . '../etc'; #set environments_location => $dirs . '../etc'; #set 'environment' => 'development';
and all works great, like I have it in my Dancer1 source/tree.
Thank you very much!
Regards
Jochen
You are welcome, we now better add that to the migration documentation. Regards Racke -- Please visit our 3rd Perl Dancer Conference 2016 in Vienna: https://www.perl.dance/.
participants (3)
-
Jochen Schnuerle -
Stefan Hornburg (Racke) -
Warren Young