其实很简单的,要先找到这个服务代码,如果是安装在/usr/local下的,那么路径应该是:/usr/local/lib/ruby/gems/1.8/gems/mongrel_cluster-1.0.5/resources
有一个文件:mongrel_cluster,内容很简单的:
[code]
#!/bin/bash
#
# Copyright (c) 2007 Bradley Taylor, bradley@railsmachine.com
#
# mongrel_cluster Startup script for Mongrel clusters.
#
# chkconfig: - 85 15
# description: mongrel_cluster manages multiple Mongrel processes for use \
# behind a load balancer.
#
CONF_DIR=/etc/mongrel_cluster
PID_DIR=/var/run/mongrel_cluster
USER=mongrel
RETVAL=0
# Gracefully exit if the controller is missing.
which mongrel_cluster_ctl >/dev/null || exit 0
# Go no further if config directory is missing.
[ -d "$CONF_DIR" ] || exit 0
case "$1" in
start)
# Create pid directory
mkdir -p $PID_DIR
chown $USER:$USER $PID_DIR
mongrel_cluster_ctl start -c $CONF_DIR
RETVAL=$?
;;
stop)
mongrel_cluster_ctl stop -c $CONF_DIR
RETVAL=$?
;;
restart)
mongrel_cluster_ctl restart -c $CONF_DIR
RETVAL=$?
;;
status)
mongrel_cluster_ctl status -c $CONF_DIR
RETVAL=$?
;;
*)
echo "Usage: mongrel_cluster {start|stop|restart|status}"
exit 1
;;
esac
exit $RETVAL
[/code]
万一找不到就拷贝上面的去好了。
把这个文件拷贝到/etc/init.d目录下,记得要用root权限。
然后创建mongrel用户(别说不会啊)。
如果是ubuntu就用命令安装缺省启动:
[code]
update-rc.d mongrel_cluster defaults
[/code]
这样实际上是在rc*.d目录下创建一系列的link,服务启动顺序很重要,例如一定要在mysql后面启动,可以直接去看一眼 /etc/rc5.d目录。一般来说都是创建了一个S20mongrel_cluster的link,修改一下文件名,改到mysql后面就行了。
比如mysql如果是 S30mysql,那么改成S40mongrel_cluster就没问题了。记得rc*.d各个目录下面都要改啊。
有一个文件:mongrel_cluster,内容很简单的:
[code]
#!/bin/bash
#
# Copyright (c) 2007 Bradley Taylor, bradley@railsmachine.com
#
# mongrel_cluster Startup script for Mongrel clusters.
#
# chkconfig: - 85 15
# description: mongrel_cluster manages multiple Mongrel processes for use \
# behind a load balancer.
#
CONF_DIR=/etc/mongrel_cluster
PID_DIR=/var/run/mongrel_cluster
USER=mongrel
RETVAL=0
# Gracefully exit if the controller is missing.
which mongrel_cluster_ctl >/dev/null || exit 0
# Go no further if config directory is missing.
[ -d "$CONF_DIR" ] || exit 0
case "$1" in
start)
# Create pid directory
mkdir -p $PID_DIR
chown $USER:$USER $PID_DIR
mongrel_cluster_ctl start -c $CONF_DIR
RETVAL=$?
;;
stop)
mongrel_cluster_ctl stop -c $CONF_DIR
RETVAL=$?
;;
restart)
mongrel_cluster_ctl restart -c $CONF_DIR
RETVAL=$?
;;
status)
mongrel_cluster_ctl status -c $CONF_DIR
RETVAL=$?
;;
*)
echo "Usage: mongrel_cluster {start|stop|restart|status}"
exit 1
;;
esac
exit $RETVAL
[/code]
万一找不到就拷贝上面的去好了。
把这个文件拷贝到/etc/init.d目录下,记得要用root权限。
然后创建mongrel用户(别说不会啊)。
如果是ubuntu就用命令安装缺省启动:
[code]
update-rc.d mongrel_cluster defaults
[/code]
这样实际上是在rc*.d目录下创建一系列的link,服务启动顺序很重要,例如一定要在mysql后面启动,可以直接去看一眼 /etc/rc5.d目录。一般来说都是创建了一个S20mongrel_cluster的link,修改一下文件名,改到mysql后面就行了。
比如mysql如果是 S30mysql,那么改成S40mongrel_cluster就没问题了。记得rc*.d各个目录下面都要改啊。