In /etc/thin/ I've got several yml files. When I run service thin stop -C /etc/thin/app.yml
thin stops all applications, instead of only the one I specified.
How do I get thin to stop/start only the specified application?
UPDATE: Hmm, in /etc/init.d/thin
there's this: $DAEMON restart --all $CONFIG_PATH
. That explains a lot. Are there smarter init.d scripts? This is my script:
https://gist.github.com/1003131
See also:
Running Rails apps with thin as a开发者_如何学运维 service
you have to edit /etc/init.d/thin adding a new action or modifying the "restart" action.
as you can see, --all $CONFIG_PATH sends the command to all thin instances.
paste the init script somewhere, we can find a decent solution ;)
UPDATE:
try to add the following lines, below this:
restart)
$DAEMON restart --all $CONFIG_PATH
;;
restart-single)
$DAEMON restart -C $2
;;
stop-single)
$DAEMON stop -C $2
;;
I didn't tried it, but it should work well. this is a really simple solution (no error checking), we've added 2 new actions that must be called as:
service thin restart-single /etc/thin/your_app.yml
or
service thin stop-single /etc/thin/your_app.yml
let me know if it works ;)
cheers, A.
I propose another solution (which i think is more thin-convenient):
set the content of your
/etc/init.d/thin
file to use my fixes:#!/bin/sh ### BEGIN INIT INFO # Provides: thin # Required-Start: $local_fs $remote_fs # Required-Stop: $local_fs $remote_fs # Default-Start: 2 3 4 5 # Default-Stop: S 0 1 6 # Short-Description: thin initscript # Description: thin ### END INIT INFO # Original author: Forrest Robertson # Do NOT "set -e" DAEMON=/usr/local/bin/thin SCRIPT_NAME=/etc/init.d/thin CONFIG_PATH=/etc/thin # Exit if the package is not installed [ -x "$DAEMON" ] || exit 0 if [ "X$2" = X ] || [ "X$3" = X ]; then INSTANCES="--all $CONFIG_PATH" else INSTANCES="-C $3" fi case "$1" in start) $DAEMON start $INSTANCES ;; stop) $DAEMON stop $INSTANCES ;; restart) $DAEMON restart $INSTANCES ;; *) echo "Usage: $SCRIPT_NAME {start|stop|restart} (-C config_file.yml)" >&2 exit 3 ;; esac :
Use
thin restart -C /etc/thin/my_website.yml
. It is possible to use such syntax withstart
,restart
andstop
commands. Yet,thin restart
(orstart
orstop
, of course) would inflict all the instances registered.
This is weird, I added a patch to the script from the gem itself for the init script for the next build to allow a single restart on future installations
restart-file) $DAEMON restart -C $2 ;;
but the gem owner refused the merge and said you can use thin start - C /path/ which is weird, because I've tried it a lot and the script itself says --all and no single config is allowed, I've also tried doing what he said and obviously it restarted all since the script uses all, can anyone shed more light to this https://github.com/macournoyer/thin/pull/176
精彩评论