Gertone (Geert Bormans)
asked on
Turn a random ruby program in a scheduled service (Windows 2003 Server)
I have a ruby program that crawls some data from a webservice
(actualy fetches a file from a http, scans the file and puts stuff in a database)
This process updates a database I use in a Rails project.
The crawling takes about 20 minutes and I want to repeat the process every two hours.
I want this all to work as a windows service
I am already running mongrel as a windows service, so it can't be that hard.
Can someone show me a quick example on how I can achieve this.
I assume there is some wrapper code, calling the win32s module,
that calls my programm every two hours, with some sort of a loop,
or can I make this run once and have a scheduled service in windows?
All hints help,
thanks
Geert
(actualy fetches a file from a http, scans the file and puts stuff in a database)
This process updates a database I use in a Rails project.
The crawling takes about 20 minutes and I want to repeat the process every two hours.
I want this all to work as a windows service
I am already running mongrel as a windows service, so it can't be that hard.
Can someone show me a quick example on how I can achieve this.
I assume there is some wrapper code, calling the win32s module,
that calls my programm every two hours, with some sort of a loop,
or can I make this run once and have a scheduled service in windows?
All hints help,
thanks
Geert
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Is this a standalone program? Or, are you calling an action in a rails project that does the fetching and loading? Perhaps a rake task? How's it set up?
I'm not sure if rubyw works as a scheduled task when you're logged out (and I don't have a Windows machine here to try it out on.) You could just make a little script that created a file or something that would test that out.
I'll be at a WinXP computer tomorrow, so if you don't have this figured out I can poke around at it.
I'm not sure if rubyw works as a scheduled task when you're logged out (and I don't have a Windows machine here to try it out on.) You could just make a little script that created a file or something that would test that out.
I'll be at a WinXP computer tomorrow, so if you don't have this figured out I can poke around at it.
Another program I had saved in my bookmarks is PyCron:
http://www.kalab.com/freeware/pycron/pycron.htm
It installs as a service and allows you to set up cron jobs. Kinda like a scheduler within a scheduler.
I haven't ever used it, just had it saved as something to try if I ever needed to. Maybe it'll work for you.
http://www.kalab.com/freeware/pycron/pycron.htm
It installs as a service and allows you to set up cron jobs. Kinda like a scheduler within a scheduler.
I haven't ever used it, just had it saved as something to try if I ever needed to. Maybe it'll work for you.
ASKER
I ended up using a scheduled task and simple ruby.exe,
as you suggested.
No need for making it a service
It works a charm, even when logged off
Thanks for your help
as you suggested.
No need for making it a service
It works a charm, even when logged off
Thanks for your help
ASKER
would that work with a scheduled task and rubyw?
do you prefer srvany.exe over the ruby library used by mongrel?
won't they conflict?
thanks for your answer sofar