in the $appdir/environments subdir there are two yml files for configuration in development and production environment. How do I configure which environment is the application running in? I tried to find it in http://search.cpan.org/dist/Dancer/lib/Dancer/Config.pm but could not find it. Gabor http://szabgab.com/
On Wed, Dec 15, 2010 at 12:44:14AM +0200, Gabor Szabo wrote:
in the $appdir/environments subdir there are two yml files for configuration in development and production environment.
How do I configure which environment is the application running in?
I tried to find it in http://search.cpan.org/dist/Dancer/lib/Dancer/Config.pm but could not find it.
Hi Gabor, You could pass it as a command-line argument. $ myapp.pl --environment=production But I put it right in the script: BEGIN { push @ARGV, qw(--environment=production) } Cheers, Joel
Gabor http://szabgab.com/ -- Joel Roth
On Wed, Dec 15, 2010 at 4:11 AM, Joel Roth <joelz@pobox.com> wrote:
On Wed, Dec 15, 2010 at 12:44:14AM +0200, Gabor Szabo wrote:
in the $appdir/environments subdir there are two yml files for configuration in development and production environment.
How do I configure which environment is the application running in?
I tried to find it in http://search.cpan.org/dist/Dancer/lib/Dancer/Config.pm but could not find it.
Hi Gabor,
You could pass it as a command-line argument.
$ myapp.pl --environment=production
I think that the rationale is that you don't have to keep the same configuration file with two different sets of values in the different environments, not even for a single configuration line to tell whether it's a development or a production environment, so leaving the option to the command-line invocation is a sane choice because it defers the decision up to the very last moment and this is not written anywhere (supposing you know in which environment you are!).
But I put it right in the script:
BEGIN { push @ARGV, qw(--environment=production) }
This solution seems to require a modification of the script when you deploy the application, which might introduce a potential for error if you forget this post-deploy activity. Of course it depends on your deploy strategy - e.g. do you redeploy the script all the times? - and on many other factors - e.g. do I control both the development and the production environments? I'd push the laziness a bit more and keep two scripts (development.pl and production.pl) in the bin directory each with the trick above, in order to avoid the need to do any kind of post-deploy activities. At this point it's only a matter of calling the right script. Keeping two shell wrappers might be another option (even though I'd avoid it in a CGI deploy). Just my 2c, Flavio.
Hmm, my production environment does not use that script. It is using the dispatch.cgi in the public directory. Which I just opened and was surprised to see that it runs the script. Strange. For that case I think an environment variable in %ENV could be also useful for setting the, well, environment. Anyway I also have two different development environments. One of them is a Linux box where I use Apache and it is quite similar to the deployment environment but needs a few different config values. The other one is a Windows box where I run the script and use the built-in web server. Can I have more that two environments ? Gabor http://szabgab.com/
Anyway I also have two different development environments. One of them is a Linux box where I use Apache and it is quite similar to the deployment environment but needs a few different config values. The other one is a Windows box where I run the script and use the built-in web server. Can I have more that two environments ?
you can set your environment with: "export DANCER_ENVIRONMENT=production" if you use plack, Dancer will use the one set by plack. To configure plack environment, you can use "plackup -E production" or "export PLACK_ENVIRONMENT=production"
On IRC, franck realized that he had mistyped his reply to Gabor : it's PLACK_ENV , not PLACK_ENVIRONMENT that's all, dams On 15 December 2010 09:31, franck <franck@lumberjaph.net> wrote:
Anyway I also have two different development environments. One of them is a Linux box where I use Apache and it is quite similar to the deployment environment but needs a few different config values. The other one is a Windows box where I run the script and use the built-in web server. Can I have more that two environments ?
you can set your environment with:
"export DANCER_ENVIRONMENT=production"
if you use plack, Dancer will use the one set by plack. To configure plack environment, you can use
"plackup -E production"
or
"export PLACK_ENVIRONMENT=production"
_______________________________________________ Dancer-users mailing list Dancer-users@perldancer.org http://www.backup-manager.org/cgi-bin/listinfo/dancer-users
participants (5)
-
damien krotkine -
Flavio Poletti -
franck -
Gabor Szabo -
Joel Roth