How to run thin in the vps after the terminal window is closed

612 Views Asked by At

Hey guys After several weeks of local testing, I'm now setting up a VPS, and try to run rails on it. At this point, I can open up a Terminal session and ssh to the VPS, run the thin start, then I the server is running ok, But as soon as I closed the terminal the thin is down.

How can I make thin server running in the VPS all the time?

another question how to change from test mode to production mode in rails.

Thanks

3

There are 3 best solutions below

0
On BEST ANSWER

Demonize thin, run it with -d flag.

thin -d 
0
On

For the task at hand you will want to use a tool called Screens

Install it:

sudo apt-get install screen

Then to run it you run:

screen -d executable

To put screen to background: Ctrl+D

To recall a screen: screen -r.

You should be all good now.

0
On

You don't really want to launch and stop thin by hand. You want it to be a daemon to be started when your system start and to be managed like any other daemons (e.g. nginx, syslog, sshd, etc.). How to do this is very distribution-dependent, but you should definitely have a look at /etc/init.d/ or /etc/rc.d/ and /etc/rc.conf. To go in production mode within the command line you use thin -e production, but the preferred way should be to specify it in thin's configuration files. You should have (or create) an /etc/thin/ folder, with one .yml file for each application you're deploying.