Solved

Turn a random ruby program in a scheduled service (Windows 2003 Server)

Posted on 2008-06-23
5
456 Views
Last Modified: 2008-07-01
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
0
Comment
Question by:Geert Bormans
  • 3
  • 2
5 Comments
 
LVL 14

Accepted Solution

by:
wesgarrison earned 500 total points
ID: 21850975
I normally just use Task Scheduler for this.  Any reason it has to be a service?

If you use the 'rubyw.exe' executable, it won't open a console window.

If it won't run as a Scheduled Task, you can use srvany.exe from the Resource Kit Tools:
http://www.microsoft.com/downloads/details.aspx?familyid=9d467a69-57ff-4ae7-96ee-b18c4790cffd&displaylang=en
0
 
LVL 60

Author Comment

by:Geert Bormans
ID: 21852295
I need to log off the machine,
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
0
 
LVL 14

Expert Comment

by:wesgarrison
ID: 21852551
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.
0
 
LVL 14

Expert Comment

by:wesgarrison
ID: 21852562
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.
0
 
LVL 60

Author Comment

by:Geert Bormans
ID: 21906020
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
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Suggested Solutions

I recently rediscovered rails when I needed a holiday project and decided to build a management dashboard for the company where I work.  With it being a project done in my free time, I could focus my time on learning the basics rather than trying to…
In Ruby, Call or invoke a API DLL library is easily via Win32API class, win32-api gem or other gems. For general DLL API call, there are quite a few references, some good tips list below: http://www.rubytips.org/2008/05/13/accessing-windows-api-fro…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now