|Newbie questions about Pliant
Running (Cron) Jobs
Need to run jobs in the HTTP server/database context.
|Message posted by maybe Boris Reitman on 2007/05/05 12:01:39
|I want the job code to have access to the current version of the database.
My understanding is that two different pliant processes can not work on the
same database. Is this correct ?
I need to send emails to my customers at regular intervals (days) to remind them
about upcoming events (birthdays, anniversaries etc.). Right now I am going to
a pliant .page and press a button "Send Emails" which invokes the code that
iterates through db records and sends out the emails. I am doing it this way,
because I don't want to stop the HTTP server to run the job.
Is it possible to get a pliant script to be invoked in the server context ?
I could then use the standard unix cron mechanism to schedule the jobs.
Otherwise, how can I do it ?
|Message posted by maybe Hubert Tonneau on 2007/05/05 12:56:42
|You have several possibilities.
First, if you want to use the same database datas from another Pliant process,
you can do it. There are many possibilies:
. first, you call 'do_store' method from time to time in your main database
application to create a copy of it somewhere else on the disk, so that you can
safely use the copy in your second Pliant process. This should be 100% reliable.
. seconds, you just load directly the main database from your second Pliant
process. I bet this is 99.99% reliable, but you your second process MUST NOT
MODIFY the datas.
. third, with the new Pliant storage subsystem, you can have two Pliant
process with each one having a copy of the database (on the same machine or
on different one, even on machines on different sites with the connection
in the middle going down from time to time) and get automatic syncing
between the two. Also this is still not ready for production at the moment.
Will be in a fiew monthes since I'm going to use it soon for true production.
Now, about your cron task, once again,fwi you have several possibilities.
. the simplest and recommanded one is to create a Pliant thread that will do
an infinit loop with 'sleep 1' then test if it's time to work
. if you really want to use cron, use Pliant 'remote' instruction so that
your second process, launched by your 'cron' utility will make the main Pliant
process do the job. For this, you need to configure Pliant strong crypto keys,
so it might not be the easier solution at the moment due to the lack of easy
to follow howto.
|Message posted by maybe on 2007/05/05 18:07:05
|> . third, with the new Pliant storage subsystem, you can have two Pliant
> process with each one having a copy of the database (on the same machine or
> on different one, even on machines on different sites with the connection
> in the middle going down from time to time) and get automatic syncing
> between the two. Also this is still not ready for production at the moment.
> Will be in a fiew monthes since I'm going to use it soon for true production.
my job modifies the data.
> . if you really want to use cron, use Pliant 'remote' instruction so that
> your second process, launched by your 'cron' utility will make the main Pliant
> process do the job. For this, you need to configure Pliant strong crypto keys,
> so it might not be the easier solution at the moment due to the lack of easy
> to follow howto.
Would I be able to edit the script and run it several times ?
because if it would get compiled into the server process after the first remote call,
how could I recompile if it changes ?
The beauty of working in the .page environment, is that it gets recompiled.
|Message posted by maybe Hubert Tonneau on 2007/05/05 18:43:20
|Well, you have found your own answer in facts.
Put your code in a .page
then use your cron to start another Pliant or Unix process that will request
the URL (with secret password provided in the URL) so that your code get
|Message posted by maybe Boris Reitman on 2007/05/05 19:52:08
|Would it be possible to use existing pliant "command" mechanism
(or to create something equivalent) to have generic code to
invoke any function that takes string and integer arguments ?
pliant_call "http://.../admin_page.html" command "..."
This way I do not need to place jobs in separate .page files with default action
to invoke them on page load.
|Message posted by maybe Hubert Tonneau on 2007/05/05 23:43:02
|I don't understand what you would like to do.
|Message posted by maybe Boris Reitman on 2007/05/06 01:10:19
|Accordig to your suggestion, I have to have a separate .page for every task,
or I have to do parsing of CGI arguments inside the .page to decide what job
My jobs are organized into functions. I would want, for example, to call:
which is implemented in file admin.page. So from a Bash command line,
I'd like to be able to do:
$ pliant run_job.pli "http://.../admin.page" '(send_notification_emails "mothersday")'
what kind of glue code do I need to put at the top of admin.page for this to work?
runtime_compile command ?
The reason that I don't want to break up my admin.page into pieces,
is the same reason
i don't want to use .pli files. I want to be able recompile on the spot,
and this can be only done if everything is in one .page file.
|Message posted by maybe Hubert Tonneau on 2007/05/06 01:17:23
|From what I understand of your project, the tick would be to have a
So, you can call it from the external through HTTP get of send_notification_emails.html
and it's recompiled on the fly each time you change the source code.