Chinaunix首页 | 论坛 | 博客
  • 博客访问: 84533
  • 博文数量: 36
  • 博客积分: 835
  • 博客等级: 准尉
  • 技术积分: 380
  • 用 户 组: 普通用户
  • 注册时间: 2010-07-14 09:26
文章分类

全部博文(36)

文章存档

2012年(1)

2011年(35)

我的朋友

分类: LINUX

2011-03-16 16:45:56

  1. #!/bin/bash
  2. if [ -z $1 ];then
  3. echo "请输入参数"
  4. exit
  5. fi

  6. check_ver() {
  7. echo $1 | grep -Eq '[0-9]{14}$'
  8. if [ $? -ne 0 ];then
  9. echo "请输入正确的参数版本号"
  10. exit
  11. fi
  12. }

  13. varnish_id=$(date +%Y%m%d%H%M%S)
  14. varnish="/usr/local/varnish/sbin/varnishd"
  15. varnishadm="/usr/local/varnish/bin/varnishadm"
  16. prog=$(basename $varnish)
  17. VARNISH_CONF_FILE="/home/www/config/varnish/aifang.vcl"
  18. PID=$(pgrep varnish)
  19. start_jobs() {
  20. $varnish \
  21. -u evans \
  22. -g www-data \
  23. -a :30080 \
  24. -f $VARNISH_CONF_FILE \
  25. -T 0.0.0.0:8800 \
  26. -s malloc,2G \
  27. -w 50,51200,10 \
  28. -p thread_pool_min=200 \
  29. -p thread_pool_max=4000 \
  30. -p thread_pools=4 \
  31. -p listen_depth=4096 \
  32. -p lru_interval=86400
  33. }

  34. start_check() {
  35. [ -x $varnish ] || exit 5
  36. [ -f $VARNISH_CONF_FILE ] || exit 6
  37. if [ -z "$PID" ];then
  38. echo $"Starting $prog: OK"
  39. start_jobs
  40. fi
  41. }

  42. stop_check() {
  43. [ -x $varnish ] || exit 5
  44. [ -f $VARNISH_CONF_FILE ] || exit 6
  45. if [ -z "$PID" ];then
  46. echo $"$prog not running"
  47. else
  48. kill -9 $(pgrep varnish)
  49. if [ $? -eq 0 ];then
  50. echo $"Stopping $prog: OK"
  51. else
  52. echo $"Stopping $prog Fail: "
  53. fi
  54. fi
  55. }


  56. check_reload(){
  57. [ -x $varnishadm ] || exit 5
  58. [ -f $VARNISH_CONF_FILE ] || exit 6
  59. if [ -z "$PID" ];then
  60. echo $"$prog not running"
  61. else
  62. $varnishadm -T localhost:8800 vcl.load $varnish_id $VARNISH_CONF_FILE
  63. if [ $? -eq 0 ];then
  64. $varnishadm -T localhost:8800 vcl.use $varnish_id
  65. echo $"Check $prog : OK "
  66. else
  67. echo $"Check $prog Fail: "
  68. fi
  69. fi

  70. }

  71. check_list() {
  72. if [ -z "$PID" ];then
  73. echo $"$prog not running"
  74. else
  75. $varnishadm -T localhost:8800 vcl.list
  76. fi
  77. }

  78. check_reback() {
  79. check_ver $1
  80. if [ $? -eq 0 ];then
  81. if [ -z "$PID" ];then
  82. echo $"$prog not running"
  83. else
  84. $varnishadm -T localhost:8800 vcl.use $1
  85. fi
  86. echo $"$prog Version Back $1"
  87. fi
  88. }

  89. case "$1" in
  90. start)
  91. start_check && exit 0
  92. $1
  93. ;;
  94. stop)
  95. stop_check && exit 0
  96. $1
  97. ;;
  98. reload)
  99. check_reload && exit 7
  100. $1
  101. ;;
  102. list)
  103. check_list && exit 0
  104. $1
  105. ;;
  106. reback)
  107. check_reback $2 && exit 0
  108. $1
  109. ;;
  110. *)
  111. echo $"Usage: $0 {start|stop|reload|list|reback}"
  112. exit 2
  113. esac
阅读(2036) | 评论(0) | 转发(0) |
0

上一篇:lnux架设subversion

下一篇:新增dev环境job

给主人留下些什么吧!~~