Solved

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

Posted on 2008-06-23
5
457 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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…
Article by: narshlob
If you've ever programmed in Ruby and have come across either a proc or a lambda, you might have been wondering what the difference is between the two and when you would use one over the other. This article will try to explain the difference between…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …
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.

929 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

10 Experts available now in Live!

Get 1:1 Help Now