PDA

View Full Version : Persistant Schedule Events



NeoMorph
September 21st, 2007, 07:54 AM
I'm not at all clear as to how you would go about making a scheduled event persistant though Girder restarts.

For instance I set a scheduled event and it's in the sheduled event list fine... I restart Girder and the event has gone! I'm actually generating the events in Lua if that makes it any clearer. If Girder keeps running the schedule fires perfectly. The problem is if you set up a nice set of scheduled event you don't want to lose them when you reboot the server.

I've read the Scheduler Library help contents and it mentions something about UUIDs but only in passing. There are no definitive explanations as to how they work or any examples.

Any help gratefully received once more.

harleydude
September 21st, 2007, 08:05 AM
I am having this problem as well. Just looked this morning and my events were gone. :(

Ron
September 21st, 2007, 08:07 AM
There are basically two ways.

1. Store the creation of the scheduled events in a script action and have that action fire on Girder start/script reset.
2. Use the Scheduler UI which will persist.

NeoMorph
September 21st, 2007, 08:41 AM
There are basically two ways.

1. Store the creation of the scheduled events in a script action and have that action fire on Girder start/script reset.


Thing is Ron there is no help in the help to let us know how to do this. I'm actually sending in events to Girder via SMS messages. The SMS creates an event with payloads which comprise the parameters needed to set a sheduled event. How do I go about making that shedule persistant when I can't create actions from parameters and obviously creating sheduled events from the UI is impossible this way.

For example I go away and I want the heating to turn on an hour before I get back. I find I'm going to be home around 8pm so I sms my home server and tell it to set a shedule for 7pm to turn the heating on. At 6pm there is a power outage and the system is restarted when the power comes back. Everything boots up except the shedule has gone byebye.

Ron
September 21st, 2007, 10:09 AM
It's funny how people always come up with new ways to use something that breaks how it was supposed to work! :)

I'll think about a way to persist scheduler created this way. That will however not make it into the next release.

NeoMorph
September 21st, 2007, 10:19 AM
It's funny how people always come up with new ways to use something that breaks how it was supposed to work! :)

I'll think about a way to persist scheduler created this way. That will however not make it into the next release.

Oh poot!

Oh well, at least it wasn't due to me not knowing how to do it... it just couldn't be done with the current release heh.

It's a useful feature, being able to control the server via sms. Blame danward79 for writing the plugin... I just sort of made it work a little better is all. ;)

Ron
September 21st, 2007, 10:21 AM
It *can* be done currently but it will involve a bit of lua code on your part. Basically you query your tasks properties after you create it (or use the properties you used to create the task ) and then store those in a file. Then when Girder starts up you read that file and recreate the scheduled tasks.

JohnHind
October 13th, 2007, 01:10 AM
You can alternately use the persistence functions I wrote for the scheduler UI to manually persist your own schedulers:

scheduler.SaveToXML(s, fn)

where s is either the scheduler id number or the scheduler object reference and fn is a string with the file name for the xml file.

scheduler.LoadFromXML(fn)

reloads the scheduler from an XML file.

You can simplify this further by omitting the fn in SaveToXML - the file will then be saved to the same place as the UI schedulers and will be restored automatically on a script reset or Girder startup.

At the moment there is no easy to delete an automatic persistence file of this type, but I'll fix that in the next version. However you can re-use a scheduler by deleting all the tasks, creating new tasks and then doing SaveToXML again, which will overwrite the original file.