Hi, I need to repack a Dancer-based site as a CPAN module. I remember seeing a bit of documentation about this somewhere but I can't find it at the moment. Any pointers to documentation or an example on how to do this? Thanks in advance, -- Pedro Melo http://www.simplicidade.org/ xmpp:melo@simplicidade.org mailto:melo@simplicidade.org
On Wednesday 25 May 2011 18:02:41 Pedro Melo wrote:
I need to repack a Dancer-based site as a CPAN module. I remember seeing a bit of documentation about this somewhere but I can't find it at the moment.
Any pointers to documentation or an example on how to do this?
At the most basic, change into the app dir, and: perl Makefile.PL make dist ... you should end up with a usable tarball. Simples :) As with all modules, check your MANIFEST file is up to date (listing all the files that need to be shipped). Cheers Dave P -- David Precious ("bigpresh") http://www.preshweb.co.uk/ "Programming is like sex. One mistake and you have to support it for the rest of your life". (Michael Sinz)
Hi, On Wed, May 25, 2011 at 9:17 PM, David Precious <davidp@preshweb.co.uk> wrote:
On Wednesday 25 May 2011 18:02:41 Pedro Melo wrote:
I need to repack a Dancer-based site as a CPAN module. I remember seeing a bit of documentation about this somewhere but I can't find it at the moment.
Any pointers to documentation or an example on how to do this?
At the most basic, change into the app dir, and:
perl Makefile.PL make dist
... you should end up with a usable tarball. Simples :)
That is simple. I'll try that and make sure it works when installed with a CPAN client. Thanks, -- Pedro Melo http://www.simplicidade.org/ xmpp:melo@simplicidade.org mailto:melo@simplicidade.org
Hi, On Wed, May 25, 2011 at 9:17 PM, David Precious <davidp@preshweb.co.uk> wrote:
On Wednesday 25 May 2011 18:02:41 Pedro Melo wrote:
I need to repack a Dancer-based site as a CPAN module. I remember seeing a bit of documentation about this somewhere but I can't find it at the moment.
Any pointers to documentation or an example on how to do this?
At the most basic, change into the app dir, and:
perl Makefile.PL make dist
... you should end up with a usable tarball. Simples :)
As with all modules, check your MANIFEST file is up to date (listing all the files that need to be shipped).
Tried this. It solves the packaging problem but not the installation problem. When cpan installs your module, all the statis files and views aren't installed. Bye, -- Pedro Melo http://www.simplicidade.org/ xmpp:melo@simplicidade.org mailto:melo@simplicidade.org
On Wed, May 25, 2011 at 8:02 PM, Pedro Melo <melo@simplicidade.org> wrote:
Hi,
I need to repack a Dancer-based site as a CPAN module. I remember seeing a bit of documentation about this somewhere but I can't find it at the moment.
Any pointers to documentation or an example on how to do this?
Thanks in advance,
I am also interested what other have to say about this but till some better answer comes along let me give you my 2c. As I understand many people who build CPAN-ish modules from web applications don't "INSTALL" it usin a cpan client. They install all the dependencies and then just unzip the tar.gz file of the actual application and configure the web server to use those file. I have been doing this too but with CPAN::Digger I decided I'll try to make it installable. The strategy I am trying to take is that during installation Makefile.PL copies the view/ the schema/ and the environments/ to the /share directory and then, using the "install_share" command of "Module::Install I make sure they are installed. Then I can use File::ShareDir in my code to access thos installed files. Gabor
The problem is that the definition of a "share directory" is different when writing a web application than when writing a general application, like a graphical interface (game, GUI app, etc.). The definition when writing a GUI app is that you just need a directory to just store artifact files, static xml files, blah blah blah. Once these files are written to disk, you don't really care about them anymore. If they need updating or any fiddling, it will be done on your repo, and you will redeploy a new version when you get to it. That's when File::ShareDir is great. The definition of a share directory when writing a web application is a place to put stuff that you really do need to edit on the server, and sometimes frequently. Also it's files you sometimes need to set up a back up for (such as SQLite DBs, etc.) and that's when sharedir is useless. For example, how often do you edit apache config files? I'll be damned if they're all lines up in a repository that you deploy automatically now and then to /etc/. Same goes for your static files, they aren't sitting in /usr/share/yourapp/static/. Another issue is that it's much more comfortable to have all the files together. It's comfortable to edit a distribution when it's all in the same main directory. When deploying using CPAN (and ShareDir), your files are scattered throughout the filesystem according to what they are, instead of what they are *related to*, thus making it very annoying to look at a single website as a whole. This also makes the packaging of this website (for backup purposes, for example) to be tiresome and close to insane. I thought about it quite a bit, and I think the best solution is to be able to have a policy of the installation toolchain which allows a completely new structure, to be able to say "my websites are in /var/www/" and it will put everything there in a way that is easy to play with, backup, update, redeploy, etc. Haven't gotten around to it yet. On Thu, May 26, 2011 at 9:12 AM, Gabor Szabo <szabgab@gmail.com> wrote:
On Wed, May 25, 2011 at 8:02 PM, Pedro Melo <melo@simplicidade.org> wrote:
Hi,
I need to repack a Dancer-based site as a CPAN module. I remember seeing a bit of documentation about this somewhere but I can't find it at the moment.
Any pointers to documentation or an example on how to do this?
Thanks in advance,
I am also interested what other have to say about this but till some better answer comes along let me give you my 2c.
As I understand many people who build CPAN-ish modules from web applications don't "INSTALL" it usin a cpan client. They install all the dependencies and then just unzip the tar.gz file of the actual application and configure the web server to use those file.
I have been doing this too but with CPAN::Digger I decided I'll try to make it installable. The strategy I am trying to take is that during installation Makefile.PL copies the view/ the schema/ and the environments/ to the /share directory and then, using the "install_share" command of "Module::Install I make sure they are installed.
Then I can use File::ShareDir in my code to access thos installed files.
Gabor _______________________________________________ Dancer-users mailing list Dancer-users@perldancer.org http://www.backup-manager.org/cgi-bin/listinfo/dancer-users
On Thu, May 26, 2011 at 8:29 AM, sawyer x <xsawyerx@gmail.com> wrote:
The definition of a share directory when writing a web application is a place to put stuff that you really do need to edit on the server, and sometimes frequently. Also it's files you sometimes need to set up a back up for (such as SQLite DBs, etc.) and that's when sharedir is useless. For example, how often do you edit apache config files? I'll be damned if they're all lines up in a repository that you deploy automatically now and then to /etc/. Same goes for your static files, they aren't sitting in /usr/share/yourapp/static/.
I understand that this might get tricky for a regular web app. My current use case is for a modular system, where one of the plugins adds a HTTP-based API + Admin web site. The configuration is mostly done by the modular system (I'm still figuring out how to override Dancer::Config or at least convince him to use my own tailor mode .yml config file, but that is for another post), so I don't even want end users messing with the configuration sent with the CPAN module. I basically need a way to make sure that the views/ and public/ directories are packaged properly and when installed with a regular CPAN client are placed correctly where Dancer expects them. Maybe the solution to my problem is not the solution to yours, given that the scope is smaller, but I would appreciate any thoughts on this. I'll keep playing with this to see if I can get something I can use. I'm testing this with a CPAN::Mini mirror and CPAN::Mini::Inject. Thanks in advance, -- Pedro Melo http://www.simplicidade.org/ xmpp:melo@simplicidade.org mailto:melo@simplicidade.org
Hi, On Wed, May 25, 2011 at 6:02 PM, Pedro Melo <melo@simplicidade.org> wrote:
Hi,
I need to repack a Dancer-based site as a CPAN module. I remember seeing a bit of documentation about this somewhere but I can't find it at the moment.
Ok, got something to work with a couple problems to be solved: I can package a Dancer app, deploy it via cpan/cpanm and start it up with plackup or standalone. The problems are: * test suite fails. I need to tweak Dancer::Test a bit *I think*, still looking into it; * the logger tries to create the log inside PERL5LIB: at first glance I didn't see a way to disable logging. Ideally a ENV var would be best. This is the process so far, from start to finish: 1. create a new dancer app and move into it: dancer -a w cd w 2. create a dist directory to hold the static files: mkdir -p lib/w/Dist 3. move the static files into it: mv config.yml environments public views lib/w/Dist 4. Generate a startup package like this one (adjust to the name of your app): cat > lib/w/Dist.pm <<'EOF' package w::Dist; BEGIN { my $dist = $INC{'w/Dist.pm'}; $dist =~ s/[.]pm$//g; $ENV{DANCER_APPDIR} = $dist; $ENV{DANCER_CONFDIR} = $dist; } use Dancer; use w; sub run { dance() } sub psgi_app { local $ENV{PLACK_ENV} = 1; dance() } 1; EOF 4. regen MANIFEST: rm -rf lib/w/Dist/logs egrep -v '^(lib|config.yml|environments|public|views)' MANIFEST > MANIFEST.NEW find lib -type f >> MANIFEST.NEW rm -f MANIFEST mv MANIFEST.NEW MANIFEST 5. Build your dist: perl Makefile.PL make dist 6. test your new dist: cpanm --notest w-0.1.tar.gz cd plackup -Mw::Dist -e 'w::Dist->psgi_app' perl -Mw::Dist -e 'w::Dist->run' This is of course work in progress, but most of it can be an automatic process. I'm still new to the Dancer internals, but right now I don't think I can solve the problem with the tests without changes to Dancer itself. Is there interest on a patch to make this easier, maybe as easy as a 'dancer pack-cpan' or something like this? Thank you for your feedback. Bye, -- Pedro Melo http://www.simplicidade.org/ xmpp:melo@simplicidade.org mailto:melo@simplicidade.org
participants (4)
-
David Precious -
Gabor Szabo -
Pedro Melo -
sawyer x