Abhijit Jadhav
Abhijit Jadhav

Reputation: 174

Running two server at the same time with a script(Ruby and Rails)

I am new new to Ruby on Rails. In my rails rails application I have used the two servers. One is the rails server and other one is simple ruby server.rb file. I need to start both the server with Start.sh script to deploy.

I have tried the following Code of Start.sh file. But the issue is Rail server is not starting until and unless I stop the ruby server.rb.

start.sh file code

rake ts:stop

rake ts:start

rake ts:index

ruby server.rb

rails server

I want to run both the servers through a single script

Upvotes: 0

Views: 326

Answers (1)

bpaul
bpaul

Reputation: 1949

If you are on a unix based system adding an & will start a command in the background. What you need is:

rake ts:stop
rake ts:start
rake ts:index
ruby server.rb &
rails server

For a rails project the better way to start multiple processes is to use a Procfile. Then you would start your application using a Procfile manager like foreman https://github.com/ddollar/foreman

Upvotes: 1

Related Questions