Created
July 20, 2019 06:40
-
-
Save caramelchocolate/bb02e0c86c8b878628053481060fa9dd to your computer and use it in GitHub Desktop.
特定のnginx.confを読み込み、start|restart|stopをする場合に使用するラッパー。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# nginx.conf の pid /path/nginx.pid; の調整は必要。 | |
args=${1:-""} | |
case "${args}" in | |
stop) | |
echo 'stop'; | |
;; | |
restart) | |
echo 'restart' | |
action_type=start | |
;; | |
start) | |
echo 'start' | |
action_type=start | |
;; | |
*) | |
echo "none args..." | |
exit 1 | |
esac | |
pid_file="nginx.pid" | |
if [ -e ${pid_file} ] ; then | |
pid=`cat ${pid_file}` | |
ps -p ${pid} >/dev/null | |
if [ $? -eq 0 ] ; then | |
echo "kill process ${pid}" | |
sudo kill ${pid} | |
fi | |
fi | |
if [ "${action_type}" = start ]; then | |
echo 'start...'; | |
sudo /path/nginx -c /path/nginx.conf | |
fi | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
how to use
(1) nginx start
$ sh main.sh start
(2) nginx start
$ sh main.sh restart
(3) nginx stop
$ sh main.sh stop