?
Solved

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

Posted on 2008-06-23
5
Medium Priority
?
463 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 2000 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

Industry Leaders: 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

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…
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…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

801 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