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