Stand Alone applications using Dancer
I would like to create a stand alone application with Dancer. Well actually I'll want to run it on a real web server as well but I also want to let people download it and run it without any setup. What I'd like to do is let people run my script: waltz.pl that would launch the Dancer server and then open the default browser pointing to http://localhost:3000 Has anyone done this already? How could I do this in a portable way? (Mac/Windows/Linux for now) Gabor -- Gabor Szabo http://szabgab.com/
Hi. On Sat, Apr 3, 2010 at 12:49 AM, Gabor Szabo <szabgab@gmail.com> wrote:
I would like to create a stand alone application with Dancer. Well actually I'll want to run it on a real web server as well but I also want to let people download it and run it without any setup. [...] Has anyone done this already? How could I do this in a portable way? (Mac/Windows/Linux for now)
This is the default usage of a Dancer script, as any Dancer script is a webserver onto itself. http://search.cpan.org/~xsawyerx/Dancer-1.173/lib/Dancer/Deployment.pod#Runn... This uses HTTP::Server::Simple::PSGI. On strawberry it doesn't install properly because of a test of HTTP::Server::Simple. However, a new version which should work is on CPAN, as developer release: http://search.cpan.org/~jesse/HTTP-Server-Simple-0.42_01/ It can be installed via: cpanm JESSE/HTTP-Server-Simple-0.42_01.tar.gz Hope this helps. Sawyer.
On Sat, Apr 3, 2010 at 12:58 AM, sawyer x <xsawyerx@gmail.com> wrote:
Hi.
On Sat, Apr 3, 2010 at 12:49 AM, Gabor Szabo <szabgab@gmail.com> wrote:
I would like to create a stand alone application with Dancer. Well actually I'll want to run it on a real web server as well but I also want to let people download it and run it without any setup. [...] Has anyone done this already? How could I do this in a portable way? (Mac/Windows/Linux for now)
This is the default usage of a Dancer script, as any Dancer script is a webserver onto itself.
http://search.cpan.org/~xsawyerx/Dancer-1.173/lib/Dancer/Deployment.pod#Runn...
This uses HTTP::Server::Simple::PSGI. On strawberry it doesn't install properly because of a test of HTTP::Server::Simple. However, a new version which should work is on CPAN, as developer release: http://search.cpan.org/~jesse/HTTP-Server-Simple-0.42_01/
It can be installed via: cpanm JESSE/HTTP-Server-Simple-0.42_01.tar.gz
Hope this helps.
Sorry, I was not clear. The server part works. How can I launch the browser from the script and how can I do it *after* I called dance() and even better after I made sure the server is up and running already? Gabor
On Sat, Apr 3, 2010 at 1:05 AM, Gabor Szabo <szabgab@gmail.com> wrote:
How can I launch the browser from the script and how can I do it *after* I called dance()
KiokuDB::Navigator uses Browser::Open to accomplish that. I can honestly say I found it nifty. :) http://search.cpan.org/perldoc?Browser::Open You can view the usage of it in the "run" method of KiokuDB::Navigator. S.
On Sat, Apr 3, 2010 at 1:11 AM, sawyer x <xsawyerx@gmail.com> wrote:
On Sat, Apr 3, 2010 at 1:05 AM, Gabor Szabo <szabgab@gmail.com> wrote:
How can I launch the browser from the script and how can I do it *after* I called dance()
KiokuDB::Navigator uses Browser::Open to accomplish that. I can honestly say I found it nifty. :)
Hmm, I missed that one. Someone needs to improve search.cpan.org so it will find modules even if the user does not know how to search for the obvious name...
You can view the usage of it in the "run" method of KiokuDB::Navigator.
Nice. I have now this code: # TODO should be in the other way around Browser::Open::open_browser("http://localhost:3000/"); dance; and it works but could be improved. How could I launch dance in the background the easy way? (I guess --daemon is not the answer for me). Maybe a dance_on_backstage(); ? and a wait_for_dance_to_finish() so I don't need to implement the ctrl-c handling myself. dance_on_backstage(); Browser::Open::open_browser("http://localhost:3000/"); wait_for_dance_to_finish(); or maybe an even better integration in case the user launched the script with --port=4000 dance_with_the_fox() That would load Browser::Open and call Browser::Open::open_browser. I guess I am looking for suggestions how to implement these. Gabor
Dnia 2010-04-03, sob o godzinie 01:36 +0300, Gabor Szabo pisze:
On Sat, Apr 3, 2010 at 1:11 AM, sawyer x <xsawyerx@gmail.com> wrote:
On Sat, Apr 3, 2010 at 1:05 AM, Gabor Szabo <szabgab@gmail.com> wrote:
How can I launch the browser from the script and how can I do it *after* I called dance()
KiokuDB::Navigator uses Browser::Open to accomplish that. I can honestly say I found it nifty. :)
Hmm, I missed that one. Someone needs to improve search.cpan.org so it will find modules even if the user does not know how to search for the obvious name...
You can view the usage of it in the "run" method of KiokuDB::Navigator.
Nice.
I have now this code:
# TODO should be in the other way around Browser::Open::open_browser("http://localhost:3000/"); dance;
and it works but could be improved.
How could I launch dance in the background the easy way? (I guess --daemon is not the answer for me).
Maybe a dance_on_backstage(); ? and a wait_for_dance_to_finish() so I don't need to implement the ctrl-c handling myself.
dance_on_backstage(); Browser::Open::open_browser("http://localhost:3000/"); wait_for_dance_to_finish();
or maybe an even better integration in case the user launched the script with --port=4000
dance_with_the_fox()
That would load Browser::Open and call Browser::Open::open_browser.
I guess I am looking for suggestions how to implement these. Gabor _______________________________________________ Dancer-users mailing list Dancer-users@perldancer.org http://www.backup-manager.org/cgi-bin/listinfo/dancer-users
Imo simplest solution would be to just run separate thread, something like: use threads; my $t = threads->create(\&browser); dance; sub browser () { sleep 1 ; Browser::Open::open_browser("http://localhost:3000/"); } -- Mariusz Gronczewski (XANi) <xani666@gmail.com> GnuPG: 0xEA8ACE64 http://devrandom.pl
2010/4/3 XANi <xani666@gmail.com>:
Dnia 2010-04-03, sob o godzinie 01:36 +0300, Gabor Szabo pisze:
Imo simplest solution would be to just run separate thread, something like:
use threads; my $t = threads->create(\&browser); dance;
sub browser () { sleep 1 ; Browser::Open::open_browser("http://localhost:3000/"); }
I use now fork() but more or less the same idea. my $pid fork(); die if not defined $pid; if ($pid) { dance; } else { sleep 1; Browser::Open::open_browser("http://localhost:3000/"); } but that still does not take in account the --port the user can supply nor does it check if the dancer server really starter successfully. regards Gabor
On Sun, Apr 4, 2010 at 10:24 AM, Gabor Szabo <szabgab@gmail.com> wrote:
but that still does not take in account the --port the user can supply nor does it check if the dancer server really starter successfully.
To test the server started successfully, I would write a small loop that checks if I can connect to the port. Maybe Sukria will have a better idea. S.
participants (3)
-
Gabor Szabo -
sawyer x -
XANi