Forum OpenACS Development: Scheduling/Unscheduling procedure

Collapse
Posted by Denis Khitrov on
Hi!

Is any chance to unschedule procedure scheduled with
ad_schedule_proc?

I checked source codes of utilities-procs and have not found any track of unschedule option.

I need to send notification emails in 2 hours and 15 minutes before meeting. Now I do it with ns_schedule_proc, but prefer to use ad_schedule_proc to see my procs in Monitoring package.

Is it possible to make time specific notifications with Notification package. I've not found docs for this package, but only API and was not able to catch all things just looking to the API. Any advices are appretiated.

Thanks
Denis

Collapse
Posted by Andrew Piskorski on
Presumably ad_schedule_proc stashes the ns_schedule id somewhere where you can find it, so you should be able to use ns_unschedule_proc to un-schedule it. But I don't think there is any equivalent no ad_unschedule_proc procedure, to clean up the the extra info ad_schedule layers on top of ns_schedule.

Hm, actually, looking at the ad_schedule_proc code, seems it does not save the job id returned by ns_schedule_proc! I think ad_schedule_proc may itself returnt the job id, but that's not terribly useful - it should stick it in an nsv somewhere, where you can view it with the Monitoring package, etc. And we need a matching ad_unschedule_proc.

Collapse
Posted by Tom Jackson on

Yes, Andrew, that would be nice. If you don't save the id, I don't think there is any way to recover it later.

Collapse
Posted by Denis Khitrov on
I can adjust ad_schedule_proc to save ID and implement ad_unschedule_proc, but this is a part of ASC core and it seems not a good idea to make customization in this part.

If I write a fix and new proc, what should I do to add it to the new version of ACS?

Collapse
Posted by Don Baccus on
If you can improve ad_schedule_proc and add an ad_unshedule_proc that would be great, just open a bug/feature in the bugtracker and submit a patch when you've finished ... reference this thread in your description of it ...
Collapse
Posted by Denis Khitrov on
OK! I will try to do it during next week.
Collapse
Posted by Jeff Davis on
It's easy enough to get the id back out, if you look at [ns_info scheduled]...
foreach item [ns_info scheduled] {
    # match on [lindex $item 8] break if found.
}
Collapse
Posted by Denis Khitrov on
Thanks Jeff!
I was looking for an option to get a list of all scheduled procedures, but have not fund it in AOL API. And I was  wondering why it's not there . But as I understand from your code "ns_info scheduled" is what I was looking for.
Collapse
Posted by Denis Khitrov on
Hi Jeff!

I've just unsaccessfuly spent more then a hour, trying to find any documentation for "ns_info scheduled". Where did you read about that feature?

It really works and returns a list of scheduled proc infos, but there is no any mention of "scheduled" option of "ns_info" in AOL docs (at least I've not found it). Can you please give me an advice where can I read about it.

Thanks

Collapse
Posted by Jeff Davis on
I got it out of a telemetry page I have been using for a while.
look at http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/aolserver/nstelemetry/nstelemetry.adp
for the source.  I think you have to read the ns_info command
source to know all the secret little things it does.
Collapse
Posted by Denis Khitrov on
Thanks.
Telemetry script was only a thing where I found a track of "ns_info scheduled".

Thinking about this AOL Server option I got another question. If it's possible to use native AOLServer function to monitor scheduled procedures, do OpenACS really needs wrappers like ad_schedule_proc/ad_unschedule_proc?

Collapse
12: Some proposals. (response to 1)
Posted by Denis Khitrov on
Hi! I came little bit deeper in scheduling related codes and found some simple ideas that may improve it. I think there are two ways to optimize scripts related to scheduling:

1. Do not use wrapper, but just user native AOL Server features. As I see from the code the only use of wrappers is to keep consitancy of monitoring information. For monitoring needs ns_info scheduled should be enough .

Hence, wrappers is good from porting point of view.

2. In current version ad_schedule_proc save proc_info to the shared variables and pass the same info to the ad_run_schedule_proc. This way do not alllows to have proc_id returned by ns_schedule_proc in both proc_infos, passed to the ad_run_schedule_proc, and in shared vars. proc_id may be stored only in shared vars, couse this value is unknown at the moment of ns_schedule_proc execution.

I propose to pass only index of the proc_info in shared var to the ad_run_schedule_proc instead of all proc_info.
This way will also simplify ad_run_schedule_proc code.

Collapse
Posted by Denis Khitrov on

There was no response to my proposals for rewriting scheduling stuff, so I've decided just extend the code from 4.6.1. I've just updloaded a patch with new function and some updates of old functions.

I still don't not like how this stuff is implemented, and hope to get any other opinions.

I also modified Monitoring package - added unscheduling option. Doing that I get another idea - what if add options like PAUSE, START, STOP. In this case all scheduled procedures will be always in the list, but not all will be runnig. It may be considered as "SERVICES".

Collapse
Posted by Don Baccus on
You might look at the cronjob package ... for more complex scheduling of stuff managed via the web it would seem like we should use this ...
Collapse
Posted by Christian Brechbuehler on
I entered a suggestion in bugtracker. It suggests recording (and passing through) the id that ad_schedule_proc gets from ns_schedule_proc, rather than throwing it away. I will provide a patch that implements it shortly. However, I won't apply such a change before someone more experienced reviews and approves my contribution.

That said, Dennis Khitrov's suggestion of relying on AOLserver's functionality, specifically the undocumented [ns_info scheduled], has a lot of appeal. It would be simpler and more robust than then current solution. But it would be a bigger change.

Collapse
Posted by Malte Sussdorff on
Nowing that AOLserver sometimes is a moving target and taking into account that ns_info scheduled is undocumented I would opt for fixing ad_schedule_proc to store the schedule id in the NSV array. That said, I haven't looked at the code in detail, but I would be willing to take a glance at your solution.
Collapse
Posted by Christian Brechbuehler on
Hi Malte, yes, please do take a glance: https://openacs.org/bugtracker/openacs/patch?patch_number=822
My solution aims at minimal changes to existing code.