Centos-Thin Web server for Ruby (install thin in centos and run rails)

Source: Internet
Author: User
ArticleDirectory
    • 1. Install thin
    • 2. Start and Stop thin
    • 3. Cluster
    • 4. runlevels
    • 5. Run rails
1. Install thin
 
Gem install thin

He will need some gem support.

 
Rack-0.9.1Eventmachine-0.12.6Daemons-1.0.10Thin-1.0.0

Of course, it will be installed automatically.

2. Start and Stop thin

Run the following command in the root directory of the rails project:

 
Thin start-d

Adding-D enables him to run in the background without adding it. When we stop thin, we can directly use Ctrl + C.

Append "-e production" to run in the production environment, append "-P 3003" to the specified port, and specify port 3003 here

 
Thin stop

Stop thin

3. Cluster
 
Thin start -- servers 3
 
Thin stop -- servers 3
4. runlevels

You can add thin to runlevel (/etc/init. d /)

 
Sudo thin install

Add scripts for the default runlevels

 
Sudo/sbin/chkconfig -- level 345 thin on

Note:

An error may occur here, indicating that thin cannot be found.

Run this command.

 
Sudo mV/etc/rc. d/thin/etc/rc. d/init. d/thin

Then run

 
Sudo/sbin/chkconfig -- level 345 thin on

You can.

View

 
Sudo/sbin/chkconfig -- list thin

Will display

 
Thin 0: off 1: off 2: On 3: On 4: On 5: on 6: Off
5. Run rails

Now let's define which rails project will run at the restart.

For example, our tails project is here

 
/Home/demo/public_html/testapp/

We want him to start in production mode under three thin' services when starting.

Sudo thin config-C/etc/thin/testapp. yml-C/home/demo/public_html/testapp/-- servers 3-e Production

Take a look at the generated/Etc/thin/testapp. yml File

 
CAT/etc/thin/testapp. yml

Display

 
PID: TMP/PIDs/Thin. pidlog: Log/Thin. logtimeout:30Port:3000Max_conns:1024Max_persistent_conns:512Environment: productionchdir:/Home/demo/public_html/Testapprequire: [] address:0.0.0.0Servers:3Daemonize:True

We can see that servers and environment are set. Of course, we can also add or modify other command parameters we want, such as the port number.

OK

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.