[Dancer-users] how to run function from app from command line?

Alex Kalderimis alex at flymine.org
Sat Jul 2 12:16:52 CEST 2011


I use Dancer::Config->load in my db management scripts for this kind of thing (having access to settings). Just remember to set the environment and appdir settings first.

Alex.

-----
sent from my phone - please excuse any brevity

----- Reply message -----
From: "Nick Knutov" <mail at knutov.com>
To: "Flavio Poletti" <polettix at gmail.com>
Cc: "Dancer Users" <dancer-users at perldancer.org>
Subject: [Dancer-users] how to run function from app from command line?
Date: Sat, Jul 2, 2011 8:33 am


Well, but I need access to Dancer environment - config, etc. First way 
does not suited for this, I think.

02.07.2011 13:13, Flavio Poletti пишет:
> Factor out the functionality you need into another module, then call it
> both from the Dancer front-end and from a script crafted for the command
> line.
>
> Another approach would be looking at the Dancer's testing
> modules/functions, they are geared at simulating calls without having a
> running instance. I'd go for the first approach, anyway.
>
> Cheers,
>
>      Flavio.
>
>
> On Fri, Jul 1, 2011 at 11:14 PM, Nick Knutov <mail at knutov.com
> <mailto:mail at knutov.com>> wrote:
>
>     Hello,
>
>     I have a big project running on Dancer. This project has some
>     service scripts (to do some cron jobs for example), written as
>     functions in this Dancer app, that should have access to all usual
>     environment (as called from the web functions have), but I need to
>     be able run them from command line.
>
>     What is the best way to do it?
>
>     Example:
>
>     get '/service_func' => {...};
>
>     I want to do something like
>
>     # ./bin/app.pl <http://app.pl> --run=service_func
>
>
>     --
>     Best Regards,
>     Nick Knutov
>     http://knutov.com
>     ICQ: 272873706
>     Voice: +7-904-84-23-130 <tel:%2B7-904-84-23-130>
>     _________________________________________________
>     Dancer-users mailing list
>     Dancer-users at perldancer.org <mailto:Dancer-users at perldancer.org>
>     http://www.backup-manager.org/__cgi-bin/listinfo/dancer-users
>     <http://www.backup-manager.org/cgi-bin/listinfo/dancer-users>
>
>

-- 
Best Regards,
Nick Knutov
http://knutov.com
ICQ: 272873706
Voice: +7-904-84-23-130
_______________________________________________
Dancer-users mailing list
Dancer-users at perldancer.org
http://www.backup-manager.org/cgi-bin/listinfo/dancer-users
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.backup-manager.org/pipermail/dancer-users/attachments/20110702/01579d8e/attachment.htm>


More information about the Dancer-users mailing list