Showing posts with label Ruby. Show all posts
Showing posts with label Ruby. Show all posts

2009-10-22

Simple Ruby and Bloomberg

I have been looking for very simple Bloomberg code.  I have used this post from bgimpert on Wilmott as a starting point.  I have copied at the bottom of this post in case it disappears.

My very simplest code is showing both historical data and static data is:

require 'win32ole'
bb =WIN32OLE.new('Bloomberg.Data.1')
bb.BLPGetHistoricalData2(["SPX Index"],["PX_LAST"],Time.now,"USD")

bb.BLPSubscribe(["EUE LN Equity"],["ID_ISIN"])

which returns the latest date and value pair.

Digging around is helped by inspection eg

bb.ole_get_methods

bgimper post on Wilmott
Or in Ruby, with no worries about dependencies or references or DLL's:
require 'win32ole'
class Bloomberg
ONE_YEAR = 60 * 60 * 24 * 365.25
DAILY_PERIODICITY = 1
WEEKLY_PERIODICITY = 6
MONTHY_PERIODICITY = 7
ANNUAL_PERIODICITY = 9
OMIT_NON_TRADING_DAYS = 0
WEEK_NON_TRADING_DAYS = 64
ALL_CALENDAR_NON_TRADING_DAYS = 128
BLOOMBERG_HANDLES_NON_TRADING_DAY_VALUE = 0
PREVIOUS_DAYS_NON_TRADING_DAY_VALUE = 256
SHOW_NO_NUMBER_NON_TRADING_DAY_VALUE = 512
def initialize
@bloomberg = WIN32OLE.new('Bloomberg.Data.1')
@bloomberg["ActivateRealtime"] = false
@bloomberg["Periodicity"] = DAILY_PERIODICITY
@bloomberg["DisplayNonTradingDays"] = OMIT_NON_TRADING_DAYS
@bloomberg["NonTradingDayValue"] = PREVIOUS_DAYS_NON_TRADING_DAY_VALUE
end
def get_stock_price_history(ticker, start_time = Time.now - ONE_YEAR)
prices = @bloomberg.BLPGetHistoricalData2(["#{ticker} UN Equity"], ["PX_LAST"], start_time, "USD")
prices.map do |price_ar|
day_s, price = price_ar
if price_ar.empty?
nil
else
[DateTime.parse(day_s), price.to_f]
end
end.compact
end
end
bb = Bloomberg.new
bb.get_stock_price_history("GE").each do |ar|
day, price = ar
puts "day = #{day}, price = #{price}"
end

2009-09-18

Creating Windows Exe

Just to note that I have migrated to using OCRA for packaging Ruby.  It is a bit slow unpacking and starting compared to EXERB but is more widely supported.  I had a problem packaging Watir which was resolved with OCRA.  It works really nicely and will work with Ruby 1.9. 

I used to use rubyscript2exe but that has ossified although it had wonderful documentation.

2009-09-03

Exerb Command reference for Ruby translated from Japanese by Google and tidied by me

Exerb Project 4.20

Welcome to "Command Reference

Command Reference

Contents

  1. Overview
  2. command exerb
    1. Parameters
    2. Options
  3. command mkexy
    1. Parameters
    2. Options

1. Overview

Exerb to include two single command. Exerb command to generate an executable file to generate a recipe file mkexy command.

2. Exerb command

Ruby script file, or specify a recipe file to generate an executable file.

exerb [option] (Ruby script file | files) recipe

1. Parameter

Ruby script to specify a file name or recipe. Can not specify multiple file names. The file name extension "rb" as if the Ruby script file, otherwise it is treated as a recipe file.

Ruby script file is specified, Ruby will generate an executable file that contains only the script. Ruby single software consists of a simple script that will be used to convert the executable.

Recipe file is specified, the executable file is generated according to the information contained in the recipe. Multiple Ruby script, a software library that consists of extended and used to convert the executable. File formats Recipes Reference, please refer to the recipe.

2. Options

You can specify the following options. If the same item at the specified recipe file and command options, command option will take precedence.

Options
Description

-c
-- corename
Specifies the name defined in the core. If -C option is specified at the same time,-C is the preferred option.

-C
-- corefile
Specifies the core file path.  -c option is specified at the same time,-C is the preferred option.

-o
-- outfile
Specifies the output file name.

-k
-- kcode
Specifies the character code. none, euc, sjis, utf8 Please specify one of them.

-a -a
--archive
Generates only archive. Executable file is not generated.

-v -v
-- verbose
Redundant information to display.

-e -e
-- execute
Run the executable file generated.

-i
-- config
Displays various settings.

-V
-- version
Displays version information.

-h
-- help
Displays the help message.

3. Mkexy command

Ruby is running the script automatically generates a recipe file. Please start one of the following ways.

mkexy [option] Ruby Script File Parameters

ruby-r exerb / mkexy [option] Ruby Script File Parameters

1. Parameter

"Ruby script file" in the recipe file is generated for the specified Ruby script. Ruby is running the specified script file is generated at the end of recipes.

"Parameters" in the recipe file to be created to specify the arguments passed to the Ruby script.

2. Options

Will ruby option to accept commands.

Copyright (C) 2001-2006 All rights reserved.

Creating Ruby exes using FX ruby

Just wanted to note this post for creating a single exe.  First using exerb  http://lylejohnson.name/blog/2008/12/30/building-standalone-fxruby-applications-with-exerb/  I tried withrubyscript2exe but something went wrong and I just quickly tried exerb.  This worked although the exe files are huge at 9MB.

The key part is

1) creating the recipe file .exy

ruby -r exerb/mkexy hello2.rb

2) Converting the recipe file to an .exe

exerb hello2.rb

I ran into a problem with gruff as it seemed to have too many files.  I am trying to work out a solution.

Part of the block looked like this:

RMagick.rb:
  file: c:/ruby/lib/ruby/gems/1.8/gems/rmagick-2.9.0-x86-mswin32/lib/RMagick.rb
c:/ruby/lib/ruby/gems/1.8/gems/gruff-0.3.4/lib/gruff/deprecated.rb:
c:/ruby/lib/ruby/gems/1.8/gems/gruff-0.3.4/lib/gruff/base.rb:
c:/ruby/lib/ruby/gems/1.8/gems/gruff-0.3.4/lib/gruff/area.rb:
c:/ruby/lib/ruby/gems/1.8/gems/gruff-0.3.4/lib/gruff/bar_conversion.rb:
c:/ruby/lib/ruby/gems/1.8/gems/gruff-0.3.4/lib/gruff/bar.rb:
c:/ruby/lib/ruby/gems/1.8/gems/gruff-0.3.4/lib/gruff/line.rb:
c:/ruby/lib/ruby/gems/1.8/gems/gruff-0.3.4/lib/gruff/pie.rb:
c:/ruby/lib/ruby/gems/1.8/gems/gruff-0.3.4/lib/gruff/spider.rb:
c:/ruby/lib/ruby/gems/1.8/gems/gruff-0.3.4/lib/gruff/net.rb:
c:/ruby/lib/ruby/gems/1.8/gems/gruff-0.3.4/lib/gruff/stacked_mixin.rb:
c:/ruby/lib/ruby/gems/1.8/gems/gruff-0.3.4/lib/gruff/stacked_area.rb:
c:/ruby/lib/ruby/gems/1.8/gems/gruff-0.3.4/lib/gruff/stacked_bar.rb:
c:/ruby/lib/ruby/gems/1.8/gems/gruff-0.3.4/lib/gruff/side_bar.rb:
c:/ruby/lib/ruby/gems/1.8/gems/gruff-0.3.4/lib/gruff/side_stacked_bar.rb:
c:/ruby/lib/ruby/gems/1.8/gems/gruff-0.3.4/lib/gruff/a_b.rb:
c:/ruby/lib/ruby/gems/1.8/gems/gruff-0.3.4/lib/gruff/accumulator_bar.rb:
c:/ruby/lib/ruby/gems/1.8/gems/gruff-0.3.4/lib/gruff/scene.rb:
c:/ruby/lib/ruby/gems/1.8/gems/gruff-0.3.4/lib/gruff/mini/legend.rb:
c:/ruby/lib/ruby/gems/1.8/gems/gruff-0.3.4/lib/gruff/mini/bar.rb:
c:/ruby/lib/ruby/gems/1.8/gems/gruff-0.3.4/lib/gruff/mini/pie.rb:
c:/ruby/lib/ruby/gems/1.8/gems/gruff-0.3.4/lib/gruff/mini/side_bar.rb:
gruff.rb:
  file: c:/ruby/lib/ruby/gems/1.8/gems/gruff-0.3.4/lib/gruff.rb

 

and I converted it to:

RMagick.rb:
   file: c:/ruby/lib/ruby/gems/1.8/gems/rmagick-2.9.0-x86-mswin32/lib/RMagick.rb
./gruff/deprecated.rb:
   file: c:/ruby/lib/ruby/gems/1.8/gems/gruff-0.3.4/lib/gruff/deprecated.rb
./gruff/base.rb:
   file: c:/ruby/lib/ruby/gems/1.8/gems/gruff-0.3.4/lib/gruff/base.rb
./gruff/area.rb:
   file: c:/ruby/lib/ruby/gems/1.8/gems/gruff-0.3.4/lib/gruff/area.rb
./gruff/bar_conversion.rb:
   file: c:/ruby/lib/ruby/gems/1.8/gems/gruff-0.3.4/lib/gruff/bar_conversion.rb
./gruff/bar.rb:
   file: c:/ruby/lib/ruby/gems/1.8/gems/gruff-0.3.4/lib/gruff/bar.rb
./gruff/line.rb:
   file: c:/ruby/lib/ruby/gems/1.8/gems/gruff-0.3.4/lib/gruff/line.rb
./gruff/pie.rb:
   file: c:/ruby/lib/ruby/gems/1.8/gems/gruff-0.3.4/lib/gruff/pie.rb
./gruff/spider.rb:
   file: c:/ruby/lib/ruby/gems/1.8/gems/gruff-0.3.4/lib/gruff/spider.rb
./gruff/net.rb:
   file: c:/ruby/lib/ruby/gems/1.8/gems/gruff-0.3.4/lib/gruff/net.rb
./gruff/stacked_mixin.rb:
   file: c:/ruby/lib/ruby/gems/1.8/gems/gruff-0.3.4/lib/gruff/stacked_mixin.rb
./gruff/stacked_area.rb:
   file: c:/ruby/lib/ruby/gems/1.8/gems/gruff-0.3.4/lib/gruff/stacked_area.rb
./gruff/stacked_bar.rb:
   file: c:/ruby/lib/ruby/gems/1.8/gems/gruff-0.3.4/lib/gruff/stacked_bar.rb
./gruff/side_bar.rb:
   file: c:/ruby/lib/ruby/gems/1.8/gems/gruff-0.3.4/lib/gruff/side_bar.rb
./gruff/side_stacked_bar.rb:
   file: c:/ruby/lib/ruby/gems/1.8/gems/gruff-0.3.4/lib/gruff/side_stacked_bar.rb
./gruff/accumulator_bar.rb:
   file: c:/ruby/lib/ruby/gems/1.8/gems/gruff-0.3.4/lib/gruff/accumulator_bar.rb
./gruff/scene.rb:
   file: c:/ruby/lib/ruby/gems/1.8/gems/gruff-0.3.4/lib/gruff/scene.rb
./gruff/mini/legend.rb:
   file: c:/ruby/lib/ruby/gems/1.8/gems/gruff-0.3.4/lib/gruff/mini/legend.rb
./gruff/mini/bar.rb:
   file: c:/ruby/lib/ruby/gems/1.8/gems/gruff-0.3.4/lib/gruff/mini/bar.rb
./gruff/mini/pie.rb:
   file: c:/ruby/lib/ruby/gems/1.8/gems/gruff-0.3.4/lib/gruff/mini/pie.rb
./gruff/mini/side_bar.rb:
   file: c:/ruby/lib/ruby/gems/1.8/gems/gruff-0.3.4/lib/gruff/mini/side_bar.rb
gruff.rb:
   file: c:/ruby/lib/ruby/gems/1.8/gems/gruff-0.3.4/lib/gruff.rb

 

It is still missing some DLL's that are needed so I will have to package those up separately.

A longer more detailed post is required on this.

2009-06-10

Gruff and Rmagick on Windows

I read this post that thought it would be very easy and just what I need to produce some graphs.  However not quite so easy as I am on Windows.  I tried gem install rmagick-win32 but then I went here to get the rmagick instructions.

http://rmagick.rubyforge.org/install-faq.html

Which worked straightforwardly.   I had previously installed imagemagick on my system.  So now hopefully gem install gruff will work. Now had a problem with the rmagick expecting to be:

C:\ruby\lib\ruby\gems\1.8\gems\rmagick-2.9.0-x86-mswin32\ext

which was due to not rebooting my computer.

The documentation is here.  I have been trying to draw a side bar with +ve and +ve variations for our daily email:

advanced_graph

However I couldn't initially get the numbers to go negative. However with sources soon have knocked up:

advanced_graph

2009-06-08

Ruby and Nozbe

Tested out gettting data from Nozbe (an excellent list manager using Dave Allens GTD methodology for inspiration) for getting reports from projects:

Using the ruby-nozbe gem it was easy to get basic information (the user key comes from your account under Extras -> API:

require 'nozbe'

user_key ='cccetc etc'

projs = Nozbe::Project.list(user_key)

projs.each {|p| puts "Id:>#{p.id}< Name:>#{p.name} Count:>#{p.count}<<"}

However the whole thing fell rather flat as I had coded all my projects using Project Groups and I couldn't get the project groups out of Nozbe.

2009-06-05

First YAML log file

I started with an excellent 5 minute tutorial and then added some a simple log file to my code.  Now I have a more or less functional log file writer.  I will improve it as I go on.

# A class for creating logfiles that show what has been done
# designed to be able to fail half way through

class H3Log
  @@default_dir = "C:"
  @@default_prefix = "Logfile"
  @@file_name = ""
  @@indent = 0
  @@indent_text = ""

  def H3Log.timestamp
    return Time.now.strftime('%Y-%m-%dT%H:%M:%S')
  end

  def H3Log.set_default_dir(dir)
    @@default_dir = dir
  end

  def H3Log.set_prefix( prefix)
    @@default_prefix = prefix
  end

  def H3Log.start(msg)
    @@file_name = "#{@@default_dir}\\#{@@default_prefix} #{Time.now.strftime('%Y-%m-%dT%H%M%S')}.yaml" if @@file_name = ""
    @@index_text = ""
    (@@indent*2).times { @@index_text += " "}
    @@indent += 1
    H3Log.msg("--- " + msg)
    H3Log.msg("start: #{H3Log.timestamp}")
  end

  def H3Log.end()
    H3Log.msg("end: #{H3Log.timestamp}")
  end

  def H3Log.msg(msg)
    f=File.open(@@file_name, 'a' )
    f.write("#{@@index_text}#{msg}\n")
    f.close
  end

end

begin
  puts "Start"
  H3Log.set_default_dir('O:\mytestdir)
  H3Log.start("log start")
  H3Log.end
rescue
  puts "had to be rescued"
end

#puts "Waiting for readline #{Time.now} "
#readline

Calling external programs

Calling external programs is easy:

system('C:\Program Files\Me\live\ClickSomething.exe')

This is a blocking call so it doesn't return control until the enclosed exe file has run.

However if you want this to click on error messages while you are controlling an application then you need it to return immediately and then to kill the process later, you need something like this:

require 'win32/process'

f = IO.popen('C:\Program Files\Me\live\ClickSomething.exe')

#do work which might generate error dialogs
Process.kill(1,f.pid)

I had loaded up popen3 earlier but I was using that to capture text output.

2009-06-02

Copy of nice Date Time Format in Ruby

I got this from here http://snippets.dzone.com/posts/show/2255

------------------------------------------------------------------- Time#strftime
time.strftime( string ) => string
---------------------------------------------------------------------------------
Formats time according to the directives in the given format string. Any text not listed as a directive will be passed through to the output string.

"
Format meaning:

%a - The abbreviated weekday name (``Sun'')
%A - The full weekday name (``Sunday'')
%b - The abbreviated month name (``Jan'')
%B - The full month name (``January'')
%c - The preferred local date and time representation
%d - Day of the month (01..31)
%H - Hour of the day, 24-hour clock (00..23)
%I - Hour of the day, 12-hour clock (01..12)
%j - Day of the year (001..366)
%m - Month of the year (01..12)
%M - Minute of the hour (00..59)
%p - Meridian indicator (``AM'' or ``PM'')
%S - Second of the minute (00..60)
%U - Week number of the current year,
starting with the first Sunday as the first
day of the first week (00..53)
%W - Week number of the current year,
starting with the first Monday as the first
day of the first week (00..53)
%w - Day of the week (Sunday is 0, 0..6)
%x - Preferred representation for the date alone, no time
%X - Preferred representation for the time alone, no date
%y - Year without a century (00..99)
%Y - Year with century
%Z - Time zone name
%% - Literal ``%'' character

t = Time.now
t.strftime("Printed on %m/%d/%Y") #=> "Printed on 04/09/2003"
t.strftime("at %I:%M%p") #=> "at 08:56AM"
"

2009-06-01

Getting Excel addins to work with Ruby

I was having difficulty with this until I came across this post by bbiker.  The problem is that when you open Excel with a program OLE link it has a different environment to that when you open manually.  Specifically addins might not work and need to be kicked.

I put it to work with the following function in the test code (this is non working code as it requires your own addin name) :

require 'win32ole'

class UpdateAddInFile

  def addin_installed?(ai)
    begin
      puts "Addins: #{ai}? =  #{@xl.AddIns(ai).Installed}"
      @xl.AddIns(ai).Installed=0
      @xl.AddIns(ai).Installed=1
    rescue
      puts "<><>Testing for adding #{ai} caused an exception."
    end
  end

  def initialize(thisFile)
    @xl = WIN32OLE.new('Excel.Application')
    @xl.Visible = true
    addin_installed?("Your Add-In")
    #Satisfying wait as Excel addins get installed
    dummy = @xl.workbooks.Add # Add a new work book
    dummy.Cells(1,1).value = "add in functions will now work"
  end

end

UpdateAddInFile.new('c:\\test.xls')

puts "Waiting for readline"
readline

2009-05-28

Ruby log file management

I have been looking for a ruby log file management.  I looked at log4r but not sure it does what I want.  I am assuming a program that is run regularly to carry out a job. I would like the following:

1) for log files to be created for each run.  These to be stored in a log file directory

2) For the log files to be managed eg stored in log\2009\2009-04 and then a log file per day and a method of multiple log files per day.

3) The log files to have a format so that they are quite happy to crash in the middle, computer turned off and still be well formed and to have written everything that has been done out safely.  IE they can’t use regular XML format as can’t rely on closing brackets

4) Ideally have a graphical hierarchical tool to show you what happened.  Eg how long does something take over time, how often has it gone wrong.  A task would log start and end events. How many have happened per month etc  Looking at graphical environements this seems more suited to a rubyfx than shoes as rubyfx has support for a tree list.  Ideally the top levels of the tree would be the file directory structure.

5) The structure to cope with hierarchical logging eg

Start A
  Start B
  End B
  Start B
End A

Shows two B inside an A, on of the B’s was unsuccessful

6) Automatic log control eg ability to have only n Months of logs, to keep only say end of month logs after 1 year and even log thinnning where old logs are first thinned by getting rid of sub levels to take up less space.  Fixed space could also be used.

I think this is as far as I have got so far now back to some real work.

Later:  I have looked at YAML and think it is going to be helpful.

2009-05-23

Playing with Ruby on rails on Windows

I have been playing with Rubymine which is a lovely development environment for Ruby.  I have a new web site development project so decided to learn Ruby on rails.

I have been reading Simply Rails 2 by Patrick Lenz and have now decided to actually try it out.  However the installation on Windows didn’t seem as straightforward as I thought it was going to be.  firstly the Instant rails seemed the wrong way to go as I already had ruby. So I did it by hand.

So I did gem install rails which worked fine.  Then downloaded rubymine and a 30 day free evaluation.  This then created my project for me.  So far so good.  I downloaded SQLite3 and put the .exe,.dll and .def in the Windows/ system32 directory, or rather I thought I did.   When I looked later Vista had prevented them.  So then I put them in c:\ruby\bin.

Had a bit of a problem with the SQL lite and I haven't been alone in this.  I created a data base with the SQL addin manager for Firefox.  Apart from using a .sqlite rather .sqlite3 that seemed ok. 

I had problems with installing the gem sqlite3-ruby and then I found this great post http://blog.emson.co.uk/2008/06/installing-sqlite3-on-windows-for-rails/

and it worked with gem install gem install sqlite3-ruby --version=1.2.3  and that seemed to work.

However ruby script/server still wouldn’t start up rails.  Time for supper.  The problem was I had corrupted the database.yaml file by adding a single character.  Once that was sorted it worked fine.

2008-06-27

Making the service a bit more robust

Windows Services series Update 2008-6-27
Having got the service up and running I wanted to be able to test the new service before running it as a service. I also needed to make it a bit more robust. This is a polled service, so every so often it will run and do something. I had my first version up and running it died but randomly after a few days (I guessed this was due to occasional problems in the guts of it eg FTP failures).
To be able to debug it easily I broke it into two parts. One file has all the guts of the service:

class ProcessFiles

def processOnce()
sleep(3)
end

end

This allows the code to be testing in a simple wrapper and run from the command line:

require 'process_files'

s = ProcessFiles.new()
while true
s.processOnce
puts "Slept for #{sleep 10} seconds"
end


Alternatively here is the a sample daemon code taken from the demo plus I added a timestamp and a comment on close:

LOG_FILE = 'C:\\test.log'
require 'process_files'


begin
require 'win32/daemon'

include Win32

class DemoDaemon < Daemon

def service_main
my_service
= ProcessFiles.new()
while running?
begin
my_service.processOnce
rescue Exception => err
File.open(LOG_FILE, "a"){ |f| f.puts "Service had a failure at #{Time.now} error=#{err} " }

sleep 10
end
sleep 3
File.open("c:\\test.log", "a"){ |f| f.puts "Service is running #{Time.now}" }
end
end

def service_stop
File.open("c:\\test.log", "a"){ |f| f.puts "***Service stopped #{
Time.now}" }
exit!
end
end

DemoDaemon.mainloop
rescue Exception => err
File.open(LOG_FILE,'a+'){ |f| f.puts " ***Daemon failure #{Time.now} err=#{err} " }
raise
end

2008-05-29

Windows Service using win32-service and win32/daemon

Windows Services series Update 2008-6-13
Rubyforge has got some good documentation on creating a daemon so I will start with that. The first thing to do is to get the demo code which doesn't come in the gem install of win32-services but can be got by downloading the zipped code.

Run through the demo (on a local drive not a networked share as the networked shares are not visible to services) and see how you go. I extracted a small version and installed with the manual service installer to make sure I could build a service.

Here is a sample daemon code taken from the demo plus I added a timestamp and a comment on close:
LOG_FILE = 'C:\\test.log'

begin
require 'win32/daemon'

include Win32

class DemoDaemon < Daemon

def service_main
while running?
sleep 3
File.open("c:\\test.log", "a"){ |f| f.puts "Service is running #{Time.now}" }
end
end

def service_stop
File.open("c:\\test.log", "a"){ |f| f.puts "***Service stopped #{
Time.now}" }
exit!
end
end

DemoDaemon.mainloop
rescue Exception => err
File.open(LOG_FILE,'a+'){ |f| f.puts " ***Daemon failure #{Time.now} err=#{err} " }
raise
end


So I copied the code to NetBeans and tried to run. I had installed win32-services (gem install win32-services), I was using Ruby 1.86 and not Jruby as the interpreter.

Make sure it has include Win32 (which is not in some early versions of the demo code) I get
daemon1.rb:28: undefined method 'mainloop' for #

With I get this due to trying to run the Daemon from the command line:
daemon1.rb:29:in `mainloop': Service_Main thread exited abnormally (Win32::Daemon::Error)

However if you create a service and then run it it will work see the following with sc.

C:\>sc create test1 binPath= "C:\ruby\bin\rubyw.exe -C c:\temp\testDaemon\lib\ main.rb" type= own start= auto
[SC] CreateService SUCCESS

C:\>sc start test1

SERVICE_NAME: test1
TYPE : 10 WIN32_OWN_PROCESS
STATE : 4 RUNNING
(STOPPABLE,PAUSABLE,ACCEPTS_SHUTDOWN)
WIN32_EXIT_CODE : 0 (0x0)
SERVICE_EXIT_CODE : 0 (0x0)
CHECKPOINT : 0x0
WAIT_HINT : 0x0
PID : 5972
FLAGS :
C:\>sc stop test1

SERVICE_NAME: test1
TYPE : 10 WIN32_OWN_PROCESS
STATE : 3 STOP_PENDING
(STOPPABLE,PAUSABLE,ACCEPTS_SHUTDOWN)
WIN32_EXIT_CODE : 0 (0x0)
SERVICE_EXIT_CODE : 0 (0x0)
CHECKPOINT : 0x0
WAIT_HINT : 0x0

C:\>

And looking at c:\Test.log you can see the results.

2008-05-28

Services on Windows series

There seem to be a number of different ways to create services on Windows using Ruby. I am going to try some of them out and see how well each one works. I was using Ruby 1.8.6.
There are two parts to this. The first is managing the service process : creating,stopping ,starting etc
The second part is packaging a Ruby script so that it can be run as that service.

The approaches I will write about are:
My plan is to summarise here the strengths and weaknesses and then to write another page for each one on exactly how to make each one work.