Solved

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

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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

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 write into a file 1 216
Can't get video.js working with firefox 6 901
Github help 2 460
what is a code editor debugger 2 185
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…
Recently I spent hours debugging an issue in a Rails project where ActiveRecord was causing MySQL errors trying to create a User object of a class at the top level of a Single Table Inheritance model structure.  It turns out `.create` behaves differ…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

825 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