Instiki
Running as a Windows Service

If you want to run instiki as a windows service, you can do it by using the programs SRVINSTW.EXE and SRVANY.EXE that come with the windows NT / 2000 / XP resource kit. If your installation is missing these programs, they are available here .

Run SRVINSTW.EXE

  1. Put both files into the system32 system directory.
  2. run SRVINSTW.EXE
  3. Select Install as a service, Local Machine
  4. Give your service any name you desire
  5. When prompted for the path to the service, give the path to SRVANY.EXE in your system32 directory
  6. Select Service is its own process
  7. Set the login credentials. On Windows, System account is the super-root: it’s the highest user in the chain, even higher than Administrator. This will work and allow Instiki access to your disks, however, it may be a security risk. You can also create a new user in Windows, give that user write permissions on the Instiki storage directory, and Instiki will be relatively sandboxed. Choice is yours.

Edit your registry

  1. Run regedit.exe
  2. Go to
    HKEY_LOCAL_MACHINE\SYSTEM\Current Control Set\Services\<your service name>
    (the name you picked in step 4 above)
  3. Add a key = ”Parameters”
  4. Add a string value = ”Application” (in the Parameters key you just created). Set this to the command to run your wiki.
    1. For Instiki 0.9.x-0.10.x
      c:\ruby\bin\ruby.exe C:\PROGRA~1\instiki-0.9.1\instiki.rb -p 2500 -t C:\PROGRA~1\instiki-0.9.1\storage\
      (or use rubyw.exe) (Using C:\PROGRA~1\... instead of “C:\Program files” will avoid some problems if instiki is in that directory)
    2. For Instiki 0.11.x
      c:\ruby\bin\ruby.exe c:\[path to instiki]\[path to script(s)\server -e production
      e.g.
      c:\ruby\bin\ruby.exe c:\instiki\script\server -e production
  5. (Optional, only try this if it doesn’t work) Add a string value = ”AppDirectory”. Set this to the path to ruby.exe. e.g.
    c:\ruby\bin\

Ensure sqlite dll is available

You can either add the path ‘[instiki home directory]\lib\native\win32’ to your path or drop the two files found there in System32

Don’t Restart your machine!

  1. Under Windows 2000/XP, you can right click My Computer, click Manage, then go to Services and Applications. Click Services, and you will see a list of all the services on the machine. Go to the service you just made, right click, and click Start. This should start the service and load Instiki!

Under Windows NT, there’s a Services applet in the Control Panel. It’s the same deal there, too.

  1. Check! Open your browser and point it to http://localhost:2500 (or if you changed the port, you know what you need to do.) Did it work?
  2. If it didn’t work, go to Control Panel>Administrative Tools>Services. Here you can find your service and change the settings. Maybe try a different User? Try System for troubleshooting. Check the Security Settings on the Instiki directory.


I found that didn’t quite work for me, but deleting Step #5 in your Registry would cause this to work properly. – Rick Smith

As an alternative to using srvinstw.exe, if you use cygwin you can use:
cygrunsrv -I Instiki -p "<path to ruby bin>/instiki.cmd" -c "<working folder>" -a "<args>"
to install the service instead. – James Frost



Just want to mention that I got Instiki to run in Cygwin as a service via this exact command:
cygrunsrv -I Instiki -p "/usr/bin/ruby" -a "/path/to/instiki/instiki" -c "/path/to/instiki/" -i

A bit different than what was suggested above by James Frost.


I used rubyw.exe at first. Unfortunately, this frequently generated “Application Error (Rails)”. Switching to just ruby.exe worked fine and didn’t show up in a DOS box which originally concerned me.



This worked great! I did not use step #5, but other than that had no problems.

The service starts without problems, but Instiki doesnt. It does if I do a “ruby instiki” though.. Now the service starts and stops without doing a thing. sigh

I had to set Application (registry, step 4) to:
c:\ruby\ininstiki.cmd—port 2500—storage c:instikistorage
It creates a command window, but I like seeing the messages. I also did not create App Directory from Registry Step 5.

I also skipped step #5. I got this to work only after I switched to putting instiki in a directory that didn’t include spaces

This worked nicely, but all text I had already put into the wiki was lost: After starting the service and connecting to it via web browser, I saw a new setup page. I chose the same wiki name as before, but the (new) wiki now was clean.

This would happen if you either changed a port or a storage directory (or didn’t specify them explicitly in the command line, using—port and—storage options, respectively).

Not necessarily: For me c:\ruby\bin\ruby.exe c:\instiki\instiki —port 2500 —storage c:instiki\storage_ works from the command line, showing my existing web, but from the Service, it opens the setup page.



The steps worked for me too, but it takes a while to start up: you can’t go to localhost:2500 immediately after you start the service. It won’t work… you have to give it a little time. – Amran

I got this to work using Microsoft’s Windows Server 2003 Resource Kit, and using instsrv.exe rather than srvinstw.exe (which I couldn’t find in the resource kit). Inputs to instsrv.exe are the service name and the path to srvany.exe. Then perform the registry edit as given above; I skipped step #5 (as also reported above) without problems. One other suggestion that I have is to put the ruby command line in a batch file and reference the batch file when setting up the Application field in the registry. This way, if you upgrade Instiki to a new version, or want to change your port or storage directory, you can make those changes in your batch file and not have to edit the registry again.

It all worked fine for me, however make sure in step #5 you set the string as “App Directory” without the space.

Using Instiki 0.11 on Windows 2000 the presence or absence of the “App Directory” string (Step #5) didn’t seem to have an effect on whether or not it worked. Following the steps suggested would only produce a blank page when the site was loaded. What I eventually did was base the command in the “Application” string value (in the registry, from Step #4) off of the information in instiki.cmd, like so:
c:\ruby\bin\ruby.exe c:\instiki\scripts\server -e production
. If you installed instiki or ruby some place else you’ll want to replace c:\ruby\bin\ if the location of your ruby binary directory and c:\instiki\ with the directory when your installed instiki.

That alone didn’t work (just loaded a blank page), I also had to add

c:\instiki\lib\native\win32
to the System PATH Enviroment Variable. If you need to find it, go to Start → Control Panel (under Settings in Windows 2000) → System (may have to “Switch to Classic View” in Windows XP) → Advanced → Enviroment Variables. Under System Variables find the variable named Path or PATH, then at the end of the string in the textbox add a semicolon (if there isn’t already one there) to seperate the path you’re about to add from the previous one and then the full path to the win32 in instiki.

Unfortunately, while most of Windows 2000 seems to notice when an enviroment variable is updated, whatever manages the services doesn’t seem to update until after a reboot (this may “corrected” in later/other versions of Windows). After the reboot, however, it worked fine. —Wholesomedick



I changed my “Application” string value to c:\instiki\instiki.cmd and then had to edit the instiki.cmd file to include the full path to my ruby and instiki installations, e.g. instead of
ruby.exe script\server -e production

use something like this:
c:\ruby\bin\ruby.exe c:\instiki\script\server -e production


My System is Windows XP SP2. It seems to me that the offical STEP #4 and STEP #5 doesn’t work. I managed myself to do a successful install with two steps.
I changed my ”Application” string value to
c:\instiki\instiki.cmd
and then changed my ”AppDirectory” string to
c:\instiki
Now it works.
Note: No need to edit the instiki.cmd although change it to include full path also works.

Win Xp SP2

Couldn’t get official steps working.

Application = “C:\httpd\instiki\instiki.cmd”
App Directory = “C:\httpd\instiki”

Edited instiki.cmd to add full paths for everything. Works fine.



ditto!


I had a lot of trouble setting up rails to run on any web server on Windows server 2003. In addition to trying to create this service I also tried mongrel, mogrel+apache and lighttpd. Nothing worked. I maganed to create the services in all cases but they all gave the same Internal error 500.

I finally got things up and running by adding the first line from the instiki.cmd file to the windows path:
.\lib\native\win32

Now both the service created with the steps suggested on this page and the mongrel service run prefectly.



like previously stated, you can also copy
\instiki\lib\native\win32\
sqlite3.dll
sqlite3_api.so
to windows\system32 or i guess any other folder that is allready on system path.



I also found the service starting but displayoing a blank page on localhost:2500. I dropped the SQLite dll and su file from \lib\native\win32\ into System32 and that did it. Rock!

I also found the service starting but displayoing a blank page on localhost:2500. I just created a batch file that opened a cmd propmt and started instiki.cmd. Put the path for the batch file into the ”Application” parameter. Now it works just fine.

Running Windows Media Center 2005 SP2 (essentially XP professional), I had to make the App Directory string c:\instiki and the Application string c:\instiki\instiki.cmd. I then had to change the instiki.cmd file to the direct, full paths. Do yourself a favor and make a copy of the file before you try editing it!!

Initially that file read

set PATH=.\lib\native\win32;PATH
ruby.exe script\server -e production

I changed it to read:

set PATH=c:\instiki\lib\native\win32;c:\ruby\bin\
ruby.exe script\server -e production

Once I did this, it worked perfectly!!!



Everything worked fine for me with the instructions provided. I know a thing or two about computers, but was completely lost following those directions. Had it not worked I probably would have given up on running it as a service, this is pretty advanced stuff for me.

This worked fine for me except one problem I don’t see mentioned here. I thought this was going to get rid of the Command Prompt Window from my taskbar and no such luck. It just starts it automatically every time I start up. I’ve still got it taking up real-estate. Windows XP, SP2, with all current patches. – Toroi


Most of the instructions worked fine for me as well, but there is one point that gave me a fit. When configuring the service initially using the SRVINSTW.EXE application, there’s another checkbox under the “system” credentials option that asks about allowing the service to interact with the desktop. I found I had to check that box for things to work properly – if not, when I tried to start the service it would pop a message saying it started, but then stopped immediately. Once that box was checked, things run fine, except as Toroi said, the cmd line is still taking up room on my task bar. I’m running Win XP Pro SP2. – Jim



It is probably best to run the service as a non-privileges account and give it rights to the folder Instiki is in. To do this, follow the instructions above, then disable the service. Make a new user account, then give it write permissions in the security tab of the folder (if you don’t see it, disable simple file sharing). In the same properties window where you disabled the service, click the Log On tab and enter the user account information. This is a heck of a lot safer than running it as a Local System account.

Make sure to restart the service after you are done.



Dittos to the “System PATH Enviroment Variable” setting that Whole Some Dick said to put in

Optimized version of “instiki.cmd”...
  • The following is a modified version of “instiki.cmd” . These changes make launching the script context agnostic (i.e. it doesn’t matter how you launch it; no need to launch from the Instiki directory in a command prompt, nor do you need to create any special shortcuts using the “Start In” directory value).
    Note: If you go the “install as a service” route for your Instiki server, this is kind of pointless.
  • The start ”” /wait /b at the beginning of the launch command line will force the DOS window to remain open until the instiki process is terminated (possibly useful for live monitoring?). If you just want to run it in the background, you can remove the start ”” /wait /b.
@ECHO OFF
CLS

SET instiki_ver=0.13.0

TITLE Running Instiki %instiki_ver% server... [CTRL+C to shutdown]

ECHO Setting environment vars ...
SET curr_dir=%~dp0
SET curr_dir=%curr_dir:~0,-1%

CD /D "%curr_dir%" 

SET path=.\lib\native\win32;%path%

ECHO Launching Instiki %instiki_ver% via Ruby.exe...
start "" /wait /b ruby.exe script\server -e production