I’ve been using D1, and just tried a fresh D2 app, and ran into a TCP port conflict, so I tried adding port: 5005 to the config.yml file generated by “dancer2 -a testapp”. On restarting, it again tries binding to TCP port 5000, not 5005. I had to pass --port 5005 to plackup to get the setting to take effect. According to this page: https://metacpan.org/pod/Dancer2::Config#port-int the D1 setting still applies to D2. It’s outdated at least insofar as it claims that the default port is 3000. Did this setting simply go away with the move to D2?
On 8/08/2015 9:08 am, Warren Young wrote:
I’ve been using D1, and just tried a fresh D2 app, and ran into a TCP port conflict, so I tried adding
port: 5005
to the config.yml file generated by “dancer2 -a testapp”. On restarting, it again tries binding to TCP port 5000, not 5005. I had to pass --port 5005 to plackup to get the setting to take effect.
The port setting only applies if you use the "inbuilt" server in Dancer2. This is sometimes useful for one liners or 'app in a script' situations and the default port is still 3000. eg: perl -E'use Dancer2; get "/" => sub { "Hello" }; dance' However if you are using one of the PSGI handlers/servers, such as plackup (standalone or with Starman, Gazelle, etc.) with the generated bin/app.psgi, those servers are responsible for the port binding. In this case you need to pass the port as an argument to that server as you noted above. If you think the docs could be clearer about this, we'd really appreciate a doc patch! Hope that helps, Russell
On Aug 8, 2015, at 5:32 AM, Russell Jenkins wrote:
perl -E'use Dancer2; get "/" => sub { "Hello" }; dance’
How useful is that, really? I mean, yes, it’s cute that you can do that, but who is actually depending on it, today? Maybe this sort of usage should be a D1-only use, and D2 should get rid of the “port” setting entirely, as part of its move to letting plackup be in charge of things like HTTP. If the real value in keeping the “port” setting is to make migration from D1 to D2 easier, why does Dancer2::Manual::Migration tell you to switch from dance() to to_app(), unconditionally?
If you think the docs could be clearer about this, we'd really appreciate a doc patch!
If Dancer 2 jettisons this bit of Dancer 1 compatibility, you get clarity the best way: by removing unnecessary detail, rather than by adding more verbiage. If plackup is in charge, the Daner2 docs can simply mention the port 5000 default, then refer to the Plack/PSGI/Starman docs for overrides. This also gets rid of $ENV{DANCER_PORT}, “has port”, etc.
participants (2)
-
Russell Jenkins -
Warren Young