Dieser Post wurde aus meiner alten WordPress-Installation importiert. Sollte es Darstellungsprobleme, falsche Links oder fehlende Bilder geben, bitte einfach hier einen Kommentar hinterlassen. Danke.
Did you find a typo in the title? No? You're right. I recently started to love the Perl Dancer Framework - and tried to write my first cronjob for a Dancer based project today.
I searched CPAN and Google - and found nothing. After digging really deep in the Dancer source, things turned out to be very easy:
- Set the DANCER_APPDIR environment variable
- use Dancer;
DANCER_APPDIR="/var/www/app" perl -MMyProject::User -le 'use Dancer; my $s = MyProject::User->new; $s->username("admin"); $s->password("admin"); $s->flush;'Very lightweight, isn't it?
(Yes, I know the password is very insecure. It's a development system and it's just a user for signin into the system and writing the user-management part, so please don't worry about the sample.)
Here is a sample for real cronjobs:
First, put this line into your crontab (and be sure that all of your projects cronjobs are below this and before the next DANCER_APPDIR line!):
DANCER_APPDIR="/var/www/myproject/"Second, add this to the very top of your script:
use Dancer;That's all!
Notice: The magic will disappear (and Dancer will start doing strange things) if you add ":syntax" to the use-line.
Noch keine Kommentare. Schreib was dazu