2008-05-27

Installing Taskr on Windows

I have had problems with the windows Task Scheduler not running applications and so looking for a more reliable replacement as well as something I could make more intelligent I choose Taskr. I started working through the installation script.

On installing:

2. Install the Taskr gem:

gem install taskr



I got this reponse:


C:>gem install taskr
Bulk updating Gem source index for: http://gems.rubyforge.org/
Successfully installed builder-2.1.2
Successfully installed markaby-0.5
Successfully installed picnic-0.6.3
Successfully installed reststop-0.2.0.50
Successfully installed openwferu-scheduler-0.9.16.1404
Successfully installed taskr-0.2.1
6 gems installed
Installing ri documentation for builder-2.1.2...
ERROR: While generating documentation for builder-2.1.2
... MESSAGE: Unhandled special: Special: type=17, text="<!-- HI -->"
... RDOC args: --ri --op c:/ruby/lib/ruby/gems/1.8/doc/builder-2.1.2/ri --title
Builder
-- Easy XML Building --main README --line-numbers --quiet lib CHANGES
Rakefile README doc/releases/builder-1.2.4.rdoc
doc/releases/builder-2.0.0.rdoc do

c/releases/builder-2.1.1.rdoc
(continuing with the rest of the installation)
Installing ri documentation for markaby-0.5...
Installing ri documentation for picnic-0.6.3...
Installing ri documentation for reststop-0.2.0.50...
Installing ri documentation for taskr-0.2.1...
Installing RDoc documentation for builder-2.1.2...
Installing RDoc documentation for markaby-0.5...
Installing RDoc documentation for picnic-0.6.3...
Installing RDoc documentation for reststop-0.2.0.50...
Installing RDoc documentation for taskr-0.2.1...


On checking my standard installation of Ruby I noticed that I hadn't
got the ActiveRecord installed. so when you try to start taskr you get
this:

C:>taskr
c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `gem_original_require': no such file to load -- active_record (MissingSourceFile)
from c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `require'
from c:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:496:in `require'
from c:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:342:in `new_constants_in'
from c:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:496:in `require'
from c:/ruby/lib/ruby/gems/1.8/gems/taskr-0.2.1/lib/taskr/environment.rb:34
from c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `gem_original_require'
from c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `require'
from c:/ruby/lib/ruby/gems/1.8/gems/taskr-0.2.1//lib/taskr.rb:17
from c:/ruby/lib/ruby/gems/1.8/gems/picnic-0.6.3/lib/picnic/cli.rb:107:in `load'
from c:/ruby/lib/ruby/gems/1.8/gems/picnic-0.6.3/lib/picnic/cli.rb:107:in `handle_cli_input'
from c:/ruby/lib/ruby/gems/1.8/gems/taskr-0.2.1/bin/taskr:35
from c:/ruby/bin/taskr:19:in `load'
from c:/ruby/bin/taskr:19

so I installed activerecord

gem install activerecord

And this time taskr did what it was supposed to and created a default configuration file which it put here

3 Run taskr from the command line. You can add the -h flag to see command line options. Also, on a Linux system you'll probably want to run Taskr as root, since by default is stores its configuration in /etc/taskr and its logs in /var/log/taskr.rb:
sudo taskr


(On Windows I was just running from the command prompt)

and I got this file:

C:\etc\taskr\config.yml

4 The first time you run the taskr command, Taskr will create a default configuration file for you in /etc/taskr/config.yml and it will then exit. Have a look inside this file and edit it to your needs. Taskr requires a SQL database, and configuration examples are provided for various database servers (MySQL, PostgreSQL, SQLite, etc.).

I wanted to run SQLite and have installed SQLite Manager into Firefox as a good management tool. I converted the file using unix2dos so that I can read it easily.
I installed the sqlite3-ruby gem

>gem install sqlite3-ruby

which installed without any trouble. It refers to webrick HTTP server and I am assuming that is built in.

I changed the default path from

dbfile: /var/lib/taskr.db

to
dbfile: /etc/taskr/taskr.db

just to keep all the files together.

5 Before running taskr again, make sure that the database you've configured is ready to be used. For example, if you're using mysql, you'll have to create the database first:
mysqladmin -u root -p create taskr


Since I was using sqlite I just used the Firefox add in to create the new data base which happened very easily.

6 You can now run taskr again. You should see it start up, and you
should be able to access the web interface at http://localhost:7007/tasks.

but I got this:



So I downloaded sqlite3.dll from www.sqlite.org - just the dll sqlitedll-3_5_9.zip. I copied both the def and dll to c:\windows\system32 and had another go at running it. This time it said it had started on localhost:7007 and was logging to taskr.log (not sure where yet).

and now it is running:



Converting to a service

The next job is to convert this to a service. There are some notes on this is done for Linux but nothing at the moment for Windows.
My route (simplified) was as follows:

Looked at this guide to using the Windows Resource Kit (2003 for XP) including the link for downloading the service. you are using srvany to run the service. I found that:
a) using the parameters key works with the Windows 2003 service kit (it is like an additional level of hierarchy and compatible with the older 2000 srvany)
b) Log on as local system account and make sure Allow Service to interact with desktop is ticked to make sure you can see what is going on.
c) in the application string you can put all the parameters eg for testing I was using
C:\windows\service32\cmd.exe /k
rather than split into an Application string and a AppParameters string.

One more gotcha - I used a baby script but it had a reference to a mapped network drive and in a service that didn't work it died. However run like this I could see it dying:
c:\ruby\bin\ruby.exe c:\baby.rb
or even
C:\windows\service32\cmd.exe /k ruby c:\baby.rb


When a process dies then the service does not stop. If you wrote a script using the win32 utilities then you could create a much better behaved script.

Taskr started up well but died towards the end. Looks like more debugging is required to get it to run under windows. Need to find what exactly is causing it to die.






No comments: