varnish.service 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. #!/bin/sh
  2. ########################################################################
  3. # Begin scriptname
  4. #
  5. # Tanım: Varnish init script
  6. #
  7. # Authors : alienus at nutyx dot org
  8. #
  9. # Version : LFS 7.5
  10. #
  11. # Notes : NuTyX Saravane
  12. #
  13. ########################################################################
  14. ### BEGIN INIT INFO
  15. # Provides: varnish init script
  16. # Required-Start:
  17. # Should-Start:
  18. # Required-Stop:
  19. # Should-Stop:
  20. # Default-Start:
  21. # Default-Stop:
  22. # Short-Tanım:
  23. # Tanım:
  24. # X-LFS-Provided-By:
  25. ### END INIT INFO
  26. . /lib/lsb/init-functions
  27. BIN='/usr/sbin/varnishd'
  28. CONF='/etc/varnish/default.vcl'
  29. PID='/var/run/varnish.pid'
  30. #
  31. # Change thoses vars to fit your need
  32. #
  33. BACKING_FILE='/var/lib/varnish'
  34. ADMIN_IP='127.0.0.1'
  35. ADMIN_PORT=8001
  36. HTTP_IP='0.0.0.0'
  37. HTTP_PORT=80
  38. CACHE_SIZE='1g'
  39. # ttl assigned to objects without ttl values (default 120s)
  40. DEFAULT_TTL=604800 # 7 days
  41. FILE_DESCRIPTORS=131072
  42. MIN_THREADS=5
  43. MAX_THREADS=500
  44. THREAD_TIMEOUT=300
  45. # maximum number of http headers (default is 64)
  46. HTTP_HEADERS=384
  47. # connection timout for backend (default is 0.4s)
  48. CONNECT_TIMEOUT='4.0'
  49. VARNISH_OPTS="-f $CONF \
  50. -s file,${BACKING_FILE},$CACHE_SIZE \
  51. -T $ADMIN_IP:${ADMIN_PORT} \
  52. -a $HTTP_IP:${HTTP_PORT} \
  53. -t $DEFAULT_TTL \
  54. -w${MIN_THREADS},${MAX_THREADS},${THREAD_TIMEOUT} \
  55. -P $PID"
  56. VARNISH_PARAMS="-p http_headers=$HTTP_HEADERS \
  57. -p connect_timeout=$CONNECT_TIMEOUT"
  58. case "${1}" in
  59. start)
  60. log_info_msg "Starting..."
  61. ulimit -n $FILE_DESCRIPTORS
  62. start_daemon $BIN $VARNISH_OPTS $VARNISH_PARAMS
  63. ;;
  64. stop)
  65. log_info_msg "Stopping..."
  66. killproc $BIN
  67. ;;
  68. restart)
  69. ${0} stop
  70. sleep 1
  71. ${0} start
  72. ;;
  73. *)
  74. echo "Usage: ${0} {start|stop|restart}"
  75. exit 1
  76. ;;
  77. esac
  78. exit 0
  79. # End scriptname