1

I have a Windows server that runs multiple Ruby apps, some requiring different Ruby versions. For managing Ruby versions we use the "PIK" Ruby version manager.

For an app we use Windows Services + SrvAny + Thin to run it. Screenshot of config:

enter image description here

However, I can't find any documentation on how to change the Ruby version for this specific Windows service. Right now, it just picks the one in the PATH env variable.

Is there a way to change ruby version using pik with Windows system services?

Simon Fredsted
  • 964
  • 2
  • 14
  • 26

2 Answers2

0

I am sure there are many ways to do what you want but one that comes to mind is editing bundle.bat which is presumably used to launch your service and adding somewhere on the top of the file a pik command to specify the version you want to use.

For example:

pik use 186 mingw

This will switch to the specified version (you can use pik list to see the ruby versions available to your system) and execute your service with this version.

See also pik's usage guide for more information.

Kostas Rousis
  • 5,918
  • 1
  • 33
  • 38
  • Thanks, I was thinking about that... I'll try it. – Simon Fredsted May 05 '14 at 13:33
  • OK, i tried adding PIK to bundle.exe. If I do that the app doesn't run at all, either via CMD.EXE or Windows Services. The first command is with @@C:\bin\pik.bat use 193@@ at the top, the last is without. http://cl.ly/image/1M2e1e3u3z15 – Simon Fredsted May 06 '14 at 06:38
  • It seems to me that it starts fine and that it's listening for connections. If you want to get rid of the warning regarding Gemfile source, just add this to your project's Gemfile: `source "https://rubygems.org"` – Kostas Rousis May 06 '14 at 06:45
  • Yes, it ran fine when I removed the PIK command. But it seems it is working if i do ""C:\bin\pik_runner.exe" "C:\bin\pik.bat" use 193" instead of just "C:\bin\pik.bat use 193", apparently the bat file halts execution somehow. – Simon Fredsted May 06 '14 at 06:59
  • Nope, service still won't run, unfortunately. – Simon Fredsted May 06 '14 at 07:01
0

You can use with pik the follow command (an example using a windows service):

pik 193 & rails server

context:

when the services run, this are using a default ruby installed, for example launch a bar.rb, then bar.rb launch other ruby server like rails server or thin server, but if you launch that with a dos command to open new instance then you can use this 2 command: pik and the desired command