How to start application from cmd.exe at windows startup?

Hello,

I searched three hours how to start my RoR application automatically as
windows starts. No information about this on internet. Maybe it’s too
easy.
Not for me !

I have installed InstantRails2.0 and i know there is a menu to start
command
prompt with ruby, but how to access this command prompt in command line
from
cmd.exe ???

If i run cmd.exe, then go to rails app directory and type “ruby
script/server” it doesn’t work because “ruby” command is not recognized.

I need to start automatically my ruby application at windows startup
(session) !

Thank you for your answers

Max

Maxime C. wrote in post #969556:

Hello,

I searched three hours how to start my RoR application automatically as
windows starts.

That depends on what you are using for a Web server.

No information about this on internet.

Sure there is, but you’re looking in the wrong place. You should be
looking at your Web server software’s docs; there’s little or nothing
Rails-specific here.

[…]

If i run cmd.exe, then go to rails app directory and type “ruby
script/server” it doesn’t work because “ruby” command is not recognized.

I need to start automatically my ruby application at windows startup
(session) !

Why do you need to do this in the first place, instead of using a real
server? (And why are you making your life harder by using Windows?)

Thank you for your answers

Max

Best,

Marnen Laibow-Koser
http://www.marnen.org
[email protected]

Sent from my iPhone

Hello Max,

In order to get the “ruby” command recognised, you need to add the
location of the ruby executable to your PATH.

The best thing is to add the “bin” folder of your InstantRails (which
contains ruby, rake, etc.) to your PATH.

Best thing is to search Google on how to add things to PATH.

Cheers,
Jits

On 20 December 2010 13:16, Maxime C. [email protected] wrote:

If i run cmd.exe, then go to rails app directory and type “ruby
script/server” it doesn’t work because “ruby” command is not recognized.

The question is not really how to start your rails app, but how to
start an InstantRails app from outside the IR environment. I did
achieve this many moons ago before I saw the light and moved to Ubuntu
(I seriously suggest you look at this possibility, you are unlikely to
regret it. There are several ways of runnning both Windows and Ubuntu
on the same machine). I forget how I did it, but I think I looked in
the IR folders and found some batch files which when I looked inside
them saw how the IR environment is setup. I think it then became
clear what to do. Alternatively, if no-one here knows how to do it
then further googling, with InstantRails as one of the keywords may be
the only possibility.

I do know that IR has not been updated for some time and is probably
not the best way (even on windows) of running RoR. VirtualRails has
been recommended if you absolutely have to stick with Windows.

As I type this I see that it has been suggested that adding the ruby
folder to the path may be sufficient, I suspect that is not all there
is to it.

Colin

On 20 December 2010 14:22, Jiten B. [email protected] wrote:

The best thing is to add the “bin” folder of your InstantRails (which
contains ruby, rake, etc.) to your PATH.

I disagree. The “best” thing to do is to not use a development
platform to try to host production sites - Don’t use InstantRails for
live.

If you have to use Windows, then look at the Bitnami Rubystack…
it’s moved on a bit since InstantRails stopped being developed.

Regards,
Michael

On 20 December 2010 13:16, Maxime C. [email protected] wrote:

I searched three hours how to start my RoR application automatically as
windows starts. No information about this on internet. Maybe it’s too easy.
Not for me !

Where were you searching?

Google for “ruby rails windows service” and you get lots of results :-/

On 20/12/2010 14:34, Michael P. wrote:

On 20 December 2010 14:22, Jiten B.[email protected] wrote:

The best thing is to add the “bin” folder of your InstantRails (which
contains ruby, rake, etc.) to your PATH.
I disagree. The “best” thing to do is to not use a development
platform to try to host production sites - Don’t use InstantRails for
live.

Totally agree with that.

It wasn’t clear to me whether the OP wanted to host something in
production or just have a Rails app available on startup on their local
machine (e.g.: a local instance of Redmine). So my suggestion was merely
in the context of the OP’s question, and was also one step (of many) on
the path to getting familiar with using Ruby.

As others have suggested, I too would highly recommend not using Windows
for any Ruby development work. Having moved to Fedora then Ubuntu after
2 years of Ruby dev on Windows I can safely say I have regained some of
my sanity back :slight_smile:

If you have to use Windows, then look at the Bitnami Rubystack…
it’s moved on a bit since InstantRails stopped being developed.

Good suggestion; +1

Jits

Maxime C. wrote:

If i run cmd.exe, then go to rails app directory and type "ruby

You received this message because you are subscribed to the Google
Groups “Ruby on Rails: Talk” group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.
There are a number of ways to do this. One way I have used is to set up
a couple of .bat files that run from startup.
start_mysql.bat

PATH C:\InstantRails\mysql\bin;%PATH%
mysqld

start_app.bat

CD C:\InstantRails\rails_apps\my_app
PATH C:\InstantRails\ruby\bin;C:\InstantRails\mysql\bin;%PATH%
ruby script\server -e production

To start your server from cmd.exe, just run ‘use_ruby.cmd’ found in the
InstantRails directory and then cd app and ‘ruby script/server’

You can also set up mysql and mongrel_rails to run as services but that
is fairly complex but doable. I do it from an installer so I would have
to extract the relevant stuff if you are interested. Let me know if you
want to see that.

Norm

Hello and thanks to all for your answers, I couldn’t expect so many
answers after a single day !

I need to run this application on Windows because it’s not on a server
but in a desktop computer in office used as workstation.

I finally found a file in the “instantrail” root folder (d’ont know
why not before…) : use_ruby.cmd which loads PATH as you told me

So from this i created a batch file loaded at windows startup with
this PATH and commands to start my ruby application.

I know there is a strong active RoR community which could help me in
the future if needed.

Best,

Max

Maxime wrote in post #969877:

Hello and thanks to all for your answers, I couldn’t expect so many
answers after a single day !

I need to run this application on Windows because it’s not on a server
but in a desktop computer in office used as workstation.

Why are you running a Rails application in that sort of context (unless
it’s for development)?

And even in that case, I’d strongly urge the use of a *nix VM.

Best,

Marnen Laibow-Koser
http://www.marnen.org
[email protected]

Sent from my iPhone

On 21 December 2010 20:50, Marnen Laibow-Koser [email protected]
wrote:

Maxime wrote in post #969877:

Hello and thanks to all for your answers, I couldn’t expect so many
answers after a single day !

I need to run this application on Windows because it’s not on a server
but in a desktop computer in office used as workstation.

Why are you running a Rails application in that sort of context (unless
it’s for development)?

I do this also (on Ubuntu though, not Windows of course). I have
several apps that I run as if they were desktop apps on my PC. One
displays data from my weather station for example. A cron task
updates the database from the weather station and the rails app
displays the data and provides administrative operations. A
conventional desktop application might be more efficient but doing it
this way gives me the option of putting the database and the app on a
server which would then allow access via the internet.

Colin

On Mon, Dec 20, 2010 at 9:07 AM, Marnen Laibow-Koser
[email protected] wrote:

Sure there is, but you’re looking in the wrong place. You should be
looking at your Web server software’s docs; there’s little or nothing
Rails-specific here.

[…]

If i run cmd.exe, then go to rails app directory and type “ruby
script/server” it doesn’t work because “ruby” command is not recognized.

are you possibly using rails 3? if so you should use, “rails server”

i assume you want to run your rails app in development mode, for
production you should seek other solutions, look into apache + mod
passenger


You received this message because you are subscribed to the Google G. “Ruby
on Rails: Talk” group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.


Kind Regards,
Rajinder Y. | DevMentor.org | Do Good! ~ Share Freely

GNU/Linux: 2.6.35-22-generic
Kubuntu x86_64 10.10 | KDE 4.5.1
Ruby 1.9.2p0 | Rails 3.0.1

Maxime you can your rails application as a window service if you are on
wondows machine.There are two exe’s that comes with windows tool kit wih
name srvany.exe and instsrv.exe .You can use them to create a windows
servcie something like below…

C:\Program Files\Resource Kit\Instsrv.exe railsapps C:\Program
Files\Resource Kit\Srvany.exe

The above command will create a windows service with name railsapps ,but
it just dummy it would not do anything.You have to follow below steps to
make it work for you.

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\railsapps\Parameters]
Application=ruby
AppParameters=script\server -b 192.168.247.49 -p 3000
AppDirectory=D:\work\railsapps