- 論壇徽章:
- 0
|
一個CS的應(yīng)用程序腳本需要符合LSB標(biāo)準(zhǔn),需要支持以下幾個參數(shù)
start start the service
stop stop the service
restart stop and restart the service if the service is already running, otherwise start the service
try-restart restart the service if the service is already running
reload cause the configuration of the service to be reloaded without actually stopping and restarting the service
force-reload cause the configuration to be reloaded if the service supports this, otherwise restart the service if it is running
status print the current status of the service
你可以在/etc/init.d/下找到一些系統(tǒng)自帶服務(wù)的啟動腳本,比如ftp什么的,一般情況下他們都可以直接使用在CS中
如果你想編寫一個第三方應(yīng)用程序的腳本,那么一個帶注釋的例子如下
- #!/bin/bash
- #
- # Copyright Red Hat Inc., 2002
- # Copyright Mission Critical Linux, 2000
- #
- # This program is free software; you can redistribute it and/or modify it
- # under the terms of the GNU General Public License as published by the
- # Free Software Foundation; either version 2, or (at your option) any
- # later version.
- #
- # This program is distributed in the hope that it will be useful, but
- # WITHOUT ANY WARRANTY; without even the implied warranty of
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- # General Public License for more details.
- #
- # You should have received a copy of the GNU General Public License
- # along with this program; see the file COPYING. If not, write to the
- # Free Software Foundation, Inc., 675 Mass Ave, Cambridge,
- # MA 02139, USA.
- #
- #
- # Author: Gregory P. Myrdal <Myrdal@MissionCriticalLinux.Com>
- #
- #
- # This file contains a template that you can use to create a script
- # that will start, stop and monitor an application used in a cluster service.
- #
- #------------------------------------------------------------
- # Variable definitions
- #------------------------------------------------------------
- MYNAME=$(basename $0)
- # The clug utility uses the normal logging levels as defined in
- # sys/syslog.h. Calls to clulog will use the logging level defined
- # for the Service Manager (clusvcmgrd).
- LOG_EMERG=0 # system is unusable
- LOG_ALERT=1 # action must be taken immediately
- LOG_CRIT=2 # critical conditions
- LOG_ERR=3 # error conditions
- LOG_WARNING=4 # warning conditions
- LOG_NOTICE=5 # normal but significant condition
- LOG_INFO=6 # informational
- LOG_DEBUG=7 # debug-level messages
- #------------------------------------------------------------
- # Start of execution
- #------------------------------------------------------------
- if [ $# -ne 2 ]; then
- echo "Usage: $0 {start, stop, status} service_name"
- exit 1
- fi
- action=$1 # type of action, i.e. 'start', 'stop' or 'status'
- svcName=$2 # name of the service
- #
- # Record all output into a temp file in case of error
- #
- exec > /tmp/$MYNAME.$action.log 2>&1
- clulog -s $LOG_DEBUG "In $0 with action=$action, svcName=$svcName"
- case $action in
- 'start')
- clulog -s $LOG_INFO "Running user start script for service $svcName"
- #
- # <<< EDIT HERE: Add service start specfic code here >>>
- #
- ;;
- 'stop')
- clulog -s $LOG_INFO "Running user stop script for service $svcName"
- #
- # <<< EDIT HERE: Add service stop specfic code here >>>
- #
- ;;
- 'status')
- clulog -s $LOG_INFO "Running user status script for service $svcName"
- #
- # <<< EDIT HERE: Add service status specfic code here >>>
- #
- ;;
- *)
- clulog -s $LOG_ERR \
- "Unknown action '$action' passed to $svcName user script"
- exit 1 # return failure
- esac
- exit 0 # return success
復(fù)制代碼
一個不符合lSB標(biāo)準(zhǔn)的腳本將導(dǎo)致,CS不停重起你的應(yīng)用程序,一個典型的例子就是httpd....oh my God !
詳情見bugzilla
https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=151104
希望能拋磚引玉,大家share出自己的腳本作品和實踐中的經(jīng)驗教訓(xùn),共同提高
[ 本帖最后由 fuumax 于 2006-12-31 13:14 編輯 ] |
|