I am new to rails . I have multiple projects in my workspace. When i hit http://localhost:3000/ , I want to know how to distinguish between different projects. Say there are three projects A,B,C in my workspace and I want to run A in my browser. How to do so ?
I hope you are familiar with rvm, and must be using that.
If you want to run a particular project. Go to your project's directory and hit rails s.
if you want to run servers of more than one projects at one time, then give the port also to run the server. e.g:
rails s -p 3001
rails s -p 3002
In your terminal locate in the folder of your project
$ cd projects_folder
$ cd project_A
$ rails s
You will see this message
=> Booting Thin
=> Rails 4.2.5 application starting in development on http://localhost:3000
=> Run `rails server -h` for more startup options
=> Ctrl-C to shutdown server
Thin web server (v1.6.4 codename Gob Bluth)
Maximum connections set to 1024
Listening on localhost:3000, CTRL+C to stop
Minimize your terminal and open http://localhost:3000 in your favorite browser.
When you want to change of project maximize your terminal and
press ctrl+c to stop the process
Locate in other folder
$ cd ..
$ cd project_B
$ rails s
I recommend you read this to learn how to navigate in terminal
Related
I'm currently using cloud 9 for this project. When I run it using rails server -b $IP -p $PORt it gives me this:
=> Booting Puma
=> Rails 5.0.0 application starting in development on http://0.0.0.0:8080
=> Run `rails server -h` for more startup options
A server is already running. Check /home/ubuntu/workspace/saasapp/tmp/pids/server.pid.
Exiting
Does anyone know how to fix this? I already tried closing and re-opening the tabs again, and stop running the run project button. The language is ruby-on-rails and I'm sort of a beginner.
The error is happening because you most likely started your server, then closed the terminal before closing the server. I also had that error, but what I did was that I clicked the memory cpu disk icon on the top right corner, then clicked restart, and re-ran my server, and it started. I'm not sure if it's the proper way, but I was following a tutorial and that's what they showed.
This happens when you close the terminal tab before ending Rails.
To end Rails, find its process ID with lsof, then kill it:
lsof -i tcp:8080
[copy the PID]
kill -9 [paste PID]
bin/rails s
Alternatively, you can also find the process ID in Puma's temporary files using cat, then kill it:
kill -9 $(cat tmp/pids/server.pid)
bin/rails s
Open this file:
/home/ubuntu/workspace/saasapp/tmp/pids/server.pid as it states in the error.
The file should contain the process ID.
Copy the ID.
Open the terminal -> https://docs.c9.io/docs/terminal and run the command
sudo kill -9 {the copied ID}
Subsequently delete the ID from the server.pid file and try to start the server again
Everything worked, but then IntelliJ IDEA 14.02 has turned off, and then restart the project is not run and displays the following information :
"C:\Program Files (x86)\JetBrains\IntelliJ IDEA 14.0.2\bin\runnerw.exe" C:\tools\rubies\ruby-2.1.5-p273\bin\ruby.exe -e $stdout.sync=true;$stderr.sync=true;load($0=ARGV.shift) E:/work/my_store/bin/rails server -b 127.0.0.1 -p 3000 -e development
=> Booting WEBrick
=> Rails 4.1.8 application starting in development on http://127.0.0.1:3000
=> Run `rails server -h` for more startup options
=> Ctrl-C to shutdown server
A server is already running. Check E:/work/my_store/tmp/pids/server.pid.
Exiting
Process finished with exit code 1
in the document E:/work/my_store/tmp/pids/server.pid. only four digits
4108
I use Windows 8, how to solve this problem ?
Use the Task Manager to check if a server process is running. If it is, stop it from the task manager. If not, delete the server.pid file.
I decided all by himself. server.pid deleted file later to restart the project file server.pid again been created, I deleted it again, restarted the computer and it worked
I have deployed my rails application on EC2. It runs on two servers. One for rails application and second for DB.
When I start application using "rails s -e production&" and if I stay connected using SSH,
I can see the webpages.
As soon as I disconnect SSH I can not see the pages.
There are no errors thrown. One weird thing is "Production.log" file does not have anything.
everything is spit out on console.
You are running rails in the current ssh session. Any programs you have running during that session will stop if you disconnect. You need to set up your rails app to run as a daemon using something like Phusion Passenger.
You are basically running the built in WEBrick server that is not really meant for production so it's likely that the process is getting killed after the parent process (your ssh process) gets terminated.
You can probably tweak the configuration to make WEBrick not quit, or you can simply run your session using screen or tmux
Screen:
$ screen
$ rails s -e production &
$ screen -d
When you want to reattach:
$ screen -r
Tmux:
$ tmux
$ rails s -e production &
$ # Hit <ctrl-b><ctrl-d> to detach
When you want to reattach:
$ screen attach -t 0
Or like #datasage mentioned you can run your Rails with an actual production web server like Passenger Phusion or Unicorn.
I'm trying to run a ruby app (redmine) as thin webservice on Windows Server 2003. I've already read and done everything said here and here, but it still won't work. At the moment I've set:
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\[my_service_name]\Parameters]
Application=c:\ruby\bin\ruby.exe
AppDirectory="c:\Program Files\redmine-1.4-test"
AppParameters=c:\ruby\bin\thin start -p 3001 -e development
Running thin from command line via:
C:\Program Files\redmine-1.4-test>thin start -p 3001 -e development
works fine.
I already tested moving Redmine to a path with no spaces, which doesn't change anything.
Any idea what can be wrong? Any hints how I could track the problem down?
Make sure that you are running the new service in the account where Ruby is installed - where you can run thin normally from the command line. Edit the service from the Control Panel (services.msc) and set up the Logon tab accordingly.
How to start thin Server automatically when Server Reboots.
I have a Rails 3 project which uses Thin Server.I can manually control the thin Server from terminal.Is it possible to start thin server as background process when system reboots.
Thanks in advance.
You can use Scheduled Tasks. There's a specific trigger option for starting a task when the computer starts.
To start the process in background mode you can use the -d option of the rails command.
I suppose you need to do this:
sudo thin install #to create init.d entry for thin
sudo /usr/sbin/update-rc.d -f thin defaults # to setup it
sudo thin config -C /etc/thin/<appname>.yml -c /var/rails/<appdir> --servers 4 -e production # to generate congig file for it. If you already got config file, you can just copy it to /etc/thin/ instead of creating.
If you use rvm on your server - browse this: RVM and thin, root vs. local user.
You can also take a look at: https://github.com/opscode-cookbooks/runit