How can I change the subtle configuration?

I have inherited a Rails application and I am trying to figure it out. However, when I run:

rails s 

I get this log:

 => Booting Thin => Rails 3.2.1 application starting in development on http://0.0.0.0:3000 => Call with -d to detach => Ctrl-C to shutdown server >> Thin web server (v1.3.1 codename Triple Espresso) >> Maximum connections set to 1024 >> Listening on 0.0.0.0:3000, CTRL+C to stop 

However, this seems problematic to me, as both servers try to listen to 3000. What makes rails run thin when I run rails s ?

+4
source share
3 answers

When the thin flag is set, the rails will use this as the default server.

You can change the port using the -p option, for example, -p 3001 . There are also a few more options for setting up the environment, address binding, and the like. See the Rails guide for more information.

+5
source

Example: Padrinorb application with nginx and thin server:

Thin

 # config/thin.yml port: 3000 user: padrino group: padrino pid: tmp/pids/thin.pid timeout: 30 wait: 30 log: log/thin.log max_conns: 1024 require: [] environment: production max_persistent_conns: 512 servers: 4 threaded: true no-epoll: true daemonize: true socket: tmp/sockets/thin.sock chdir: /home/padrino/my-padrino-app tag: my-padrino-app 

Nginx

 # /etc/nginx/sites-enabled/my-padrino-app server { listen 80 default_server; server_name my-padrino-app.com; location / { proxy_pass http://padrino; } } upstream padrino { server unix:/home/padrino/my-padrino-app/tmp/sockets/thin.0.sock; server unix:/home/padrino/my-padrino-app/tmp/sockets/thin.1.sock; server unix:/home/padrino/my-padrino-app/tmp/sockets/thin.2.sock; server unix:/home/padrino/my-padrino-app/tmp/sockets/thin.3.sock; } 

Script to start, stop, restart, state

 #!/usr/bin/env bash # bin/my-padrino-app-service.sh APPDIR="/home/padrino/my-padrino-app" CURDIR=$(pwd) if [[ $# -lt 1 ]] then echo echo "Usage:" echo " $0 <start|stop|restart|status>" echo exit 1 fi case $1 in "status") cat $APPDIR/tmp/pids/thin.* &> /dev/null if [[ $? -ne 0 ]] then echo "Service stopped" else for i in $(ls -C1 $APPDIR/tmp/pids/thin.*) do echo "Running: $(cat $i)" done fi ;; "start") echo "Making thin dirs..." mkdir -p $APPDIR/tmp/thin mkdir -p $APPDIR/tmp/pids mkdir -p $APPDIR/tmp/sockets echo "Starting thin..." cd $APPDIR # Production thin start -e production -C $APPDIR/config/thin.yml cd $CURDIR sleep 2 $0 status ;; "stop") cat $APPDIR/tmp/pids/thin.* &> /dev/null if [[ $? -eq 0 ]] then for i in $(ls -C1 $APPDIR/tmp/pids/thin.*) do PID=$(cat $i) echo -n "Stopping thin ${PID}..." kill $PID if [[ $? -eq 0 ]] then echo "OK" else echo "FAIL" fi done fi $0 status ;; "restart") $0 stop $0 start $0 status ;; esac 
+5
source

You can do something like this:

thin start -p 3000 -e production .... etc. for each parameter. But it's too boring ...

The best approach is to create a yml configuration file in the app_name / config / directory.

 #config/my_thin.yml user: www-data group: www-data pid: tmp/pids/thin.pid timeout: 30 wait: 30 log: log/thin.log max_conns: 1024 require: [] environment: production max_persistent_conns: 512 servers: 1 threaded: true no-epoll: true daemonize: true socket: tmp/sockets/thin.sock chdir: /path/to/your/apps/root tag: a-name-to-show-up-in-ps aux 

and run it by specifying this configuration file: thin start -C config/mythin.yml

+3
source

Source: https://habr.com/ru/post/1399349/


All Articles