Solved

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

Posted on 2008-06-23
5
461 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How to use Rhodes without Rhosync or RhoConnect? 2 668
What is 'f.hidden_field' for? 1 321
compare two windows registry keys in chef 1 82
is this a cms? 8 74
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…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

730 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