Re: Daemontool-izing MySQL

Dmitry Volkoff <[email protected]>
Newsgroups gmane.comp.djb.syslog
Message-ID <20030815234915.GA7178@server1>
On Thu, Aug 14, 2003 at 09:41:33AM -0600, Ed Vazquez wrote:
> The svc calls to the script also fail to close the database and stop
> all the spawned processes.

Hello,

My run-script allows to control mysqld via `svc -t mysqld` and `svc -d
mysqld`. You need watchpid for that. This is how I run mysql-4.0.x under 
daemontools on linux:

# cat run
======================
#!/bin/sh

exec 2>&1

############# limits #############
# maximum number of open file descriptors 
ulimit -SHn 4096
# maximum number of user processes
ulimit -SHu 512
# maximum size of a process's data segment
ulimit -SHd 500000
##################################################

killall -9 mysqld >& /dev/null
socket=`cat env/SOCKET`
rm $socket 
ln -s /opt/service/mysqld$socket $socket

envuidgid mysql envdir ./env sh -c '
	chroot $CHROOTDIR bin/setuidgid $USER bin/mysqld	\
	--basedir=/ \
	${DEFAULTCHARSET+"--default-character-set=$DEFAULTCHARSET"}	\
	${SOCKET+"--socket=$SOCKET"} 			\
	${TCPPORT+"--port=$TCPPORT"} 			\
	${BINDADDRESS+"--bind-address=$BINDADDRESS"} 	\
	${PIDFILE+"--pid-file=$PIDFILE"}	\
	${BIGTABLES+"--big-tables"} 		\
	${SKIPNETWORKING+"--skip-networking"} 	\
	${SKIPGRANTTABLES+"--skip-grant-tables"} 	\
	${ENABLELOCKING+"--enable-locking"} 	\
	${SKIPSHOWDATABASE+"--skip-show-database"}  \
	${SKIPNAMERESOLVE+"--skip-name-resolve"} \
	${SKIPINNODB+"--skip-innodb"} \
	${MYISAMRECOVER+"--myisam-recover=$MYISAMRECOVER"} \
	${KEYBUFFER+"-Okey_buffer_size=$KEYBUFFER"} \
	${JOINBUFFERSIZE+"-Ojoin_buffer_size=$JOINBUFFERSIZE"} \
	${READ_BUFFER_SIZE+"-Oread_buffer_size=$READ_BUFFER_SIZE"} \
	${SORTBUFFER+"-Osort_buffer=$SORTBUFFER"} \
	${TMPTABLESIZE+"-Otmp_table_size=$TMPTABLESIZE"} \
	${MAXHEAPTABLESIZE+"-Omax_heap_table_size=$MAXHEAPTABLESIZE"} \
	${MAXALLOWEDPACKET+"-Omax_allowed_packet=$MAXALLOWEDPACKET"} \
	${MAXCONNECTIONS+"-Omax_connections=$MAXCONNECTIONS"} \
	${TABLECACHE+"-Otable_cache=$TABLECACHE"} \
	${MYISAMSORTBUFFER+"-Omyisam_sort_buffer_size=$MYISAMSORTBUFFER"} \
	${THREADCACHE+"-Othread_cache=$THREADCACHE"} \
	${WAITTIMEOUT+"-Owait_timeout=$WAITTIMEOUT"} \
	${DATADIR+"--datadir=$DATADIR"} \
	${LOGSLOWQUERIES+"--log-slow-queries=$LOGSLOWQUERIES"} \
	${LOGBIN+"--log-bin=$LOGBIN"} \
	${LOGUPDATE+"--log-update=$LOGUPDATE"} \
	${SERVERID+"--server-id=$SERVERID"} \
	${QUERY_CACHE_SIZE+"--query_cache_size=$QUERY_CACHE_SIZE"} \
	${QUERY_CACHE_TYPE+"--query_cache_type=$QUERY_CACHE_TYPE"} \
	${LOG+"--log=$LOG"}
' &

pidfile=/opt/service/mysqld/data/`cat env/PIDFILE`
sleep 5
exec /usr/local/bin/watchpid `cat $pidfile`
killall -9 mysqld
======================

-- 
    DV
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.