How to detach JRuby on Rails - ruby-on-rails

I created a small application using Ruby on Rails and I recently transferred it to JRuby.
The issue I have is before when I was using MRI, I used to run the server using rails server -d to run it in the background.
Now with JRuby, it seems that this option is not available and I can't just leave it in the background.
Is there a way to do this? I've found a few threads on how to this using gems like spoon but I can't find any documentation on how to install then implement it on my application
Also, it seems the answers I found are little out dated.
I was wondering, are there new gems out there that can be easily installed/used to run a JRuby on Rails app in the background?
Any guidance would be greatly appreciated. Thank you.

I am not sure what OS you are using, but on linux/unix you can put any command into the background by placing an "&" after it. for example
rails server &
or if you have it running a cntl-z and then bg should place it into the background as well.

In Ubuntu it has to be
rails s -d &
The -d stands for run in detached mode.
the & is standard UNIX for command line detach.

Related

I have a complete ruby project on my system but how do I run it?

I have a complete ruby project on my system that I downloaded from github.com and I want to run it on my Windows machine.
I have already installed Ruby and Rails on my system, but I have no idea how to run this project. The directory of this project is something like:
C:\Users\{username}\Desktop\BitcoinFundi\BitcoinFundi
How would I run this project on my system?
To run your Ruby on Rails application, use the following command:
rails server
This will start the server and you will be able to access the application in your browser at http://localhost:3000. Port 3000 is default and you can change it in the application settings.
To run a Ruby script use:
ruby name_of_script.rb
You should check out various resources and tutorials on getting started with rails.
As you say in your comment this is your first experience with Ruby on Rails, I think you should follow through chapter 1 and 2 (at least) of Ruby on Rails Tutorial. After that you should have a better understanding of how you start up a rails app and configure the DB. You also need a bunch of other libraries and software such as mysql from the sounds of it.
You should also read Getting Started with Rails. Section 4 covers how to start the default rails server.
Here is a guide on setting up a Rails environment for Windows, which is one of many guides, that shows you some of the needed steps to get a fully working environment.

Super Rails (aka using sudo with rails)

Whenever I try to create a new rails app I get a permission denied error. Yet when I try running rails as sudo it says rails is not a command. How would I use rails in a protected directory? Thanks.
If the Rails binary is not in a path that sudo can see, it won't run as sudo. This happens a lot on Ubuntu systems where the sudo environment is locked down.
I have no idea why you're having this type of problem though - the 'rails' command is meant to be run during development, and you'd usually not be working in a locked-down directory. My advice is to fix whatever permission problems you're having.
If yo're trying to create a Rails application on a server you don't control, you should know that's not the way Rails developers typically work. We usually develop locally and use some tool like Caipstrano or other scripting tool to pull the code from a version control system onto the server.
Without knowing more specifics, I'm afraid I can't be any more helpful than that. But I hope this clears some things up.

Any Xampp Like For Ruby On Rails?

I'm still new to ruby and i'm in the process to learn it, i'm actually using Xampp for php on windows, but i'm stuck at finding a complete package to install a RoR server just like Xampp without any manual work.
Is there any tool out there?
You can try Rails Installer
One of your choices is to use built in mongrel/webrick server which comes with each rails app. Just type $ rails s at the console and you're good to go. Otherwise I don't think it's particularly useful to deploy an app each time you change something.

Ruby on Rails: How to start the WEBrick server automatically on Windows in background?

In order to run the my Rails application on Windows XP I open a command line, cd to application's directory, and then run rails server.
I would like to automate this, such that every time I turn on my computer, all I'll have to do is to type localhost:3000 in a browser.
How could I do this ?
The simpler way is to create a batch file with the instruction what you give in the command prompt like
d:
cd projects\myapp
ruby script\server
and then drop a copy of the file to Windows Start -> All Programs -> start up folder.
You have few possibilities to do that.
using the registry you can use HKLM\Software\Microsoft\Windows\CurrentVersion\Run or the better approach would be to create a service, you can see this KB with some instruction how to make a service of whatever executable you want.
have you thought about , AUTOEXEC.BAT or creating some batch files. you create right cmd commands that are run at start up. http://www.aumha.org/a/batches.php
The best approach is turn your application into a service. There is a solution for Mongrel (a web server similar to webrick) called mongrel_service, but is not compatible with Rails 3 (due several changes of Rails internals)
However, you can repurpose mongrel_service codebase to work with thin, another webserver that works with Rails 3.
Please look here where is the only reference to mongrel_service script. changing it to thin start could work.
Perhaps is not the answer you're looking for (as there is some work to be done) but is something :)
start rubyw script/rails server webrick
start -> start in another console
rubyw -> run ruby detached from console

How to begin with Ruby on Rails using Windows

I've tried downloading the Rails package and installing it on Windows, but have no idea to make it work.
I have had some experience with this commbination:
PHP 4.x + 5.x (Windows)
LIGHTTPD (Windows)
Connecting to a Firebird Database (Windows)
Can anybody enlighten me?
I've gotten Rails up and running on Windows just following the instructions on the RoR website. To paraphrase:
Download Ruby Windows installer from here. I recommend this one.
Execute the .exe [ruby186-26.exe]
Verify your Windows environment variables now includes C:\ruby\bin in the PATH variable. (My Computer -> Properties -> Advanced -> Environment Variables). If it's not there, add it.
Download Ruby Gems from here.
Extract the zip [rubygems-1.3.0.zip] to a temporary directory.
Open a command window and cd to the temp directory.
Type ruby setup.rb in the command window and hit enter.
After that from the command window type gem install rails
Boom! You have rails on windows.
I've heard good things about Instant Rails I've avoided it though. I highly recommend RadRails for Eclipse. I do all my RoR development in Windows using RadRails to connect to a MySQL database.
Either try Instant Rails, which hasn't been updated in a while.
Or try this tutorial and install everything yourself: http://beans.seartipy.com/2008/06/09/setting-up-rails-development-environment-on-windows-vistaxp/
If you're really beginning and have no special attachment to the stuff you've downloaded, try getting the latest Netbeans (v6.1) which comes with Ruby and Rails build in. Its massively simple to install and get running. (A double click install). Then, once you've done that do a "File > New Project > Ruby > Ruby On Rails Application", press F6 and you'll be looking at the start page of your first Rails App.
To get to grips with it all, I'd suggest Sang Shin's free Ruby On Rails course. Its been running a while, but its free, is hands on, has some excellent material, and covers a great deal. I'm doing it and have learned a lot about Rails and Ruby also.
HTH
I use Heroku this is the Signup page for all my Rails Development
You don't have to install or set up anything and you are up and running Fast.
Also, this is a good tutorial for setting up Instant Rails on Vista:
You should really consider just install a Virtual Machine using VMWare if possible. You can still get start with Windows, but you could come across a lot of hiccups on various packages you want to use. I was from Windows too... now I switched myself to a mac and never looked back....
The point is, Ruby runs just a lot better on any POSIX other than using Windows, so its better not to try forcing anything suppose to work properly on one platform on another one. Practically, you will NEVER consider hosting a rails application in Windows (similarly, I doubted if you should ever consider hosting a PHP app in Windows too... you are just putting more cost to hurt your own feet by doing so...)
Another possibility is try to get Ubuntu setup on a USB memory/ hard drive and boot using that when you want to play Rails, slightly problematic, but better performance.
NetBeans as suggested as beginner IDE is good. Although if you get start properly with a good book (Pragmatic defacto Rails book 3rd edition is a good choice, you will never put that one down even after so long as the references are just too useful). Alternatively Rails Guide is something you shouldn't miss.
These are the best tutorials that I have seen for setting up rails on Windows.
Xp: http://www.buildingwebapps.com/articles/6467-setting-up-rails-on-windows-xp
Vista: http://www.buildingwebapps.com/articles/6491-setting-up-rails-on-windows-vista
I used this tutorial just yesterday and it worked well. BUT you need to install RubyGems yourself, after installing Ruby and before installing Rails. I found this guide helpful for RubyGems installation.
I was not able to use an environment variable to set up the http proxy; instead I must pass that as a param on the CL when installing gems (-p [myproxy].[mysite]:[port])
Late to the party, but could you try this tutorial instead?
Getting Started with Rails and MySQL
Two observations:
--source http://gems.rubyinstaller.org is no longer needed. remove that part from the command
Install latest RC1 for either 1.9.1 or 1.8.6 from here
Hope that helps
Here's some tools that have helped me in Windows for general RoR development
TextMate-like editor: http://www.e-texteditor.com/
Multi-tab SSH client: http://www.vandyke.com/products/securecrt/index.html
Full featured UNIX shell (including git): http://code.google.com/p/msysgit/
I just followed this tutorial, and it worked great the first time, and gives steps to take if you encounter common errors. I HIGHLY recommend it. it's one of the best tutorials I've ever gone through. I'm an ASP .NET guy, and I had no trouble.
My suggestion is to begin with a microframework. Something like Sinatra. You can move to Rails / Merb afterwards.
checkout Rails Windows Installer
it installs :
Ruby 1.8.7-p330
Rails 3.0.3
Git 1.7.3.1
Sqlite 3.7.3
DevKit
Rubystack is a free, all-in-one installer for Windows that installs Apache, MySQL, Ruby, Rails and all other third-party libraries typically used on a development environment (such as Imagemagick). We include PHP as well, but no lighttpd

Resources