Dancer2 icon indicating copy to clipboard operation
Dancer2 copied to clipboard

confdir config option not actually used anywhere

Open chrisspang opened this issue 9 years ago • 15 comments

I was expecting to be able to get Dancer2 to load a config from a specific directory by using the 'confdir' option. It is documented in Dancer2::Config:

DANCER_CONFDIR
 Sets the configuration directory.

 This correlates to the "confdir" config option.

It's not used anywhere in code, though.

ConfigReader.pm seems to deduce the configuration directory using some horrible code in HasLocation.pm which just trawls the file-system looking for a .dancer file (!) or a diretory with a lib and bin subdirectory (!!).

ConfigReader.pm:

has config_location => (
    is      => 'ro',
    isa     => ReadableFilePath,
    lazy    => 1,
    default => sub { $ENV{DANCER_CONFDIR} || $_[0]->location },
);

I'd rather not have my apps just use the first config they come across on the filesystem - can this be changed to use a specified directory?

chrisspang avatar Jun 01 '15 12:06 chrisspang

This relates to #408.

We should definitely support confdir again.

xsawyerx avatar Sep 19 '15 23:09 xsawyerx

Can i take this bug?

vorobeez avatar Sep 21 '15 17:09 vorobeez

@Vorobeez go for it! :smile:

veryrusty avatar Sep 21 '15 20:09 veryrusty

What we are looking for is support for the configuration option confdir which will allow someone to control where the configuration will be loaded from. Come to think of it, this might not be possible. There are two situations in which someone uses it:

  1. On the command line
  2. In the app: use Dancer2; set confdir => '...';

The first isn't supported since the command line is now plackup. We might add more options to that, but for now it's not supported.

The second is probably too late to set it, since as soon as you call use Dancer2 the configuration is loaded. I might be wrong on that, but that's the first thing you'll need to check. Then, if it's loaded lazily, we can add the support. If it's not, maybe we can load things more lazily and then add support.

xsawyerx avatar Sep 22 '15 06:09 xsawyerx

@xsawyerx, thank you for explanations. I'm going to code review. (actually, i'm started reviewing ConfigReader.pm). I wanted to say that my code review may take week or more, is it not bad? (i'm not familiar with Moose).

vorobeez avatar Sep 24 '15 18:09 vorobeez

@Vorobeez Not a problem at all. :)

xsawyerx avatar Sep 24 '15 21:09 xsawyerx

@Vorobeez how's it going with this? Anything we can help with? Please let me know! :)

cromedome avatar Oct 08 '15 16:10 cromedome

Can we put something in bin/app.psgi to set the confdir option? Or do it via an env variable. Both would be a bit confusing. Or a symbolic link from config.yml to /etc/myapp/config.yml so the confdir variable is not needed.

rleir avatar Oct 09 '15 00:10 rleir

You can set DANCER_CONFDIR. Looking through Dancer2::Core::Role::ConfigReader, this seems supported already.

I like the idea of use MyApp; set confdir => ... in my app.psgi, but I don't know how feasible that is yet. Still getting the hang of some things.

cromedome avatar Oct 09 '15 15:10 cromedome

@cromedome, hello. Sorry, i didn't have so much time to investigate this bug. Now i am reviewing Dancer2::Core:App.pm. Give me, please, one week to offer some solution.

vorobeez avatar Oct 11 '15 19:10 vorobeez

No problem! Not trying to rush you, I just wanted to make myself available if you needed anything :)

On Oct 11, 2015, at 2:22 PM, Andrew Firsov [email protected] wrote:

@cromedome, hello. Sorry, i didn't have so much time to investigate this bug. Now i am reviewing Dancer2::Core:App.pm. Give me, please, one week to offer some solution.

— Reply to this email directly or view it on GitHub.

cromedome avatar Oct 11 '15 20:10 cromedome

@cromedome, hello again. I have some questions. Maby you will answer to me?

  1. I didn't use Moo before. Will BUILD method called when you create instance of some class? (e.g. Dancer2::Core:App).
  2. I don't understand at all how Dancer2 starts. For instance i have that code:
#!/usr/bin/perl

use warnings;
use strict;
use Dancer2;

get '/' =>  sub {
    send_file('index.html');
};
dance;

What will happen after calling dance method? And when Dancer2 will call import method from Dancer.pm?

vorobeez avatar Oct 26 '15 17:10 vorobeez

The 'dance' keyword does not seem to be necessary, in fact my tests fail when it is in my code. This is off-topic; I recommend the dancer-users mailing list.

Did my comment on Oct 8 cover the confdir issue? If so, let's close this issue and focus on #408 . Thanks -- Rick

rleir avatar Nov 06 '15 13:11 rleir

Andrew/Rick,

Andrew: sorry for the delay in responding to this.

I have actually started a somewhat ambitious project to deal with the list of config related issues… covering confdir, issue 408, and more.

I should have a branch pushed on my fork sometime this weekend, I hope, and you can both see what I am working towards. Your feedback/input/patches will certainly be welcome.

Rick: I am not as convinced that ConfigReader is more complex than it needs to be. Let me get my branch cleaned up and pushed and let’s discuss some more?

Thanks! Jason

On Nov 6, 2015, at 7:34 AM, Rick Leir [email protected] wrote:

The 'dance' keyword does not seem to be necessary, in fact my tests fail when it is in my code. This is off-topic; I recommend the dancer-users mailing list.

Did my comment on Oct 8 cover the confdir issue? If so, let's close this issue and focus on #408 . Thanks -- Rick

— Reply to this email directly or view it on GitHub.

cromedome avatar Nov 06 '15 13:11 cromedome

Hello, are there any updates regarding this?

schaiba avatar Feb 25 '24 09:02 schaiba