<NME> deploy.sh
<BEF> #!/bin/bash
cur_dir=`old=\`pwd\`; cd \`dirname $0\`; echo \`pwd\`; cd $old;`
prj=`basename $cur_dir`
env=$1
iphp_dir=/data/lib/iphp
nginx_conf_dir=/etc/nginx/conf.d
fpm_pid_dir=/var/run/php-fpm
fpm_log_dir=/var/log/php-fpm
prj_dir=/data/www/$prj
dep_dir=/data/deploy_www/$prj.dep.`date +%Y%m%d_%H%M%S`

php-fpm 2>&1 > /dev/null
if [ "$?" -eq "127" ]; then
	echo "error: command php-fpm not found!"
	exit 1
fi
if [ ! -d "$iphp_dir" ]; then
	echo "error: iphp framework is not installed at $iphp_dir"
	exit 1
fi
if [ ! -d "$fpm_pid_dir" ]; then
	mkdir -p $fpm_pid_dir
fi
if [ ! -d "$fpm_log_dir" ]; then
	mkdir -p $fpm_log_dir
fi

if [ -z "$env" ]; then
	echo "Usage: $0 ENV"
	echo "    ENV: dev, online"
	exit 1
fi

deploy_dev()
{
	mkdir -p /data/applogs/$prj
	chmod ugo+rwx /data/applogs /data/applogs/$prj

	rm -f $prj_dir
	ln -sf $cur_dir $prj_dir
	ln -sf $cur_dir/app/config/config_${env}.php $cur_dir/app/config/config.php
	ln -sf $cur_dir/app/config/nginx_${env}.conf $nginx_conf_dir/$prj.conf
}

deploy_online()
{
	mkdir -p /data/applogs/$prj
	chmod ugo+rwx /data/applogs /data/applogs/$prj

	mkdir -p /data/deploy_www
	chmod ugo+rx /data/deploy_www

	echo "copy files..."
	rsync -a --exclude '.*' $cur_dir/ $dep_dir/
	if [ $? -ne "0" ]; then
		echo "Failed to deploy project!"
		exit 1
	fi
	chmod ugo+rx $dep_dir

	echo "create links..."
}

start_fpm(){
	$fpm -y $fpm_config -g $fpm_pidfile
	if [ -f "$fpm_pidfile" ]; then
		echo "php-fpm started."
	else
		echo "php-fpm failed!"
	fi
}

stop_fpm(){
	echo -n "stopping php-fpm"
	while [ 1 ]; do 
		if [ -f "$fpm_pidfile" ]; then
			echo -n "."
			kill `cat $fpm_pidfile`
		else
			echo " done."
			break
		fi
		sleep 0.5
	done
}

	echo "update assets.json fail! please resolve it!"
fi
cd $cur_dir
# end update assets.json


sh $prj_dir/server.sh restart


echo ""
echo "done."
echo "#######################################"
echo ""

<MSG> update deploy.sh

<DFF> @@ -62,25 +62,31 @@ function deploy_online()
 }
 
 start_fpm(){
+	printf "starting php-fpm..."
 	$fpm -y $fpm_config -g $fpm_pidfile
 	if [ -f "$fpm_pidfile" ]; then
-		echo "php-fpm started."
+		echo ""
+		echo "  started"
 	else
-		echo "php-fpm failed!"
+		echo ""
+		echo "  failed!"
 	fi
 }
 
 stop_fpm(){
-	echo -n "stopping php-fpm"
-	while [ 1 ]; do 
+	printf "stopping php-fpm"
+	for ((i=0; ; i++)); do
+		if [ $((i%10)) = 0 ]; then
+			printf "."
+		fi
 		if [ -f "$fpm_pidfile" ]; then
-			echo -n "."
 			kill `cat $fpm_pidfile`
 		else
-			echo " done."
+			echo ""
+			echo "  stopped"
 			break
 		fi
-		sleep 0.5
+		sleep 0.1;
 	done
 }
 

update deploy.sh