{"id":124,"date":"2010-04-27T20:56:05","date_gmt":"2010-04-27T11:56:05","guid":{"rendered":"http:\/\/blog.xcir.net\/?p=124"},"modified":"2010-05-20T18:57:03","modified_gmt":"2010-05-20T09:57:03","slug":"varnish%e3%81%a7%e5%86%8d%e8%b5%b7%e5%8b%95%e7%84%a1%e3%81%97%e3%81%a7%e8%a8%ad%e5%ae%9a%e3%83%95%e3%82%a1%e3%82%a4%e3%83%ab%e3%82%92%e9%81%a9%e7%94%a8%e3%81%99%e3%82%8b%e6%96%b9%e6%b3%95reload","status":"publish","type":"post","link":"https:\/\/blog.xcir.net\/?p=124","title":{"rendered":"Varnish\u3067\u518d\u8d77\u52d5\u7121\u3057\u3067\u8a2d\u5b9a\u30d5\u30a1\u30a4\u30eb\u3092\u9069\u7528\u3059\u308b\u65b9\u6cd5(reload)"},"content":{"rendered":"<p>Varnish\u3067\u518d\u8d77\u52d5\u3092\u4f34\u308f\u305a\u306b\u8a2d\u5b9a\u306e\u518d\u8aad\u8fbc\u3092\u884c\u3044\u305f\u3044\u3068\u304d\u306fvarnishadm\u304btelnet\u3067\u5165\u3063\u3066\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u611f\u3058\u3067\u30b3\u30de\u30f3\u30c9\u3092\u6253\u305f\u306a\u3044\u3068\u3044\u3051\u307e\u305b\u3093<\/p>\n<p>[code=&#8217;plain&#8217;]<br \/>\nvarnishadm -T 192.168.1.123:6082 vcl.load testvcl \/etc\/varnish\/default.vcl<br \/>\nvarnishadm -T 192.168.1.123:6082 vcl.use testvcl<br \/>\n[\/code]<\/p>\n<p>\u6b63\u76f4\u3081\u3093\u3069\u304f\u3055\u3044\u3067\u3059<br \/>\n\u304b\u3068\u3044\u3063\u3066\u666e\u901a\u306b\/etc\/init.d\/varnish reload\u3068\u304b\u3084\u308b\u3068\u518d\u8d77\u52d5\u3057\u3066\u3044\u3057\u307e\u3044\u305b\u3063\u304b\u304f\u6e9c\u3081\u8fbc\u3093\u3060\u30ad\u30e3\u30c3\u30b7\u30e5\u304c\u30af\u30ea\u30a2\u3055\u308c\u3066\u3057\u307e\u3044\u307e\u3059<\/p>\n<h4>\/etc\/init.d\/varnish\u306e\u4e00\u90e8\u304b\u3089<\/h4>\n<p>[code=&#8217;shell&#8217;]<br \/>\nrestart() {<br \/>\n        stop<br \/>\n        start<br \/>\n}<\/p>\n<p>reload() {<br \/>\n        restart<br \/>\n}<br \/>\n[\/code]<\/p>\n<p>\u3068\u3044\u3046\u3053\u3068\u3067graceful\u30aa\u30d7\u30b7\u30e7\u30f3\u3092\u8ffd\u52a0\u3057\u3066reload\u3082\u305d\u308c\u306b\u5272\u308a\u5f53\u3066\u3066\u307f\u307e\u3057\u305f<\/p>\n<p><a href=\"\/index.php\/2010\/04\/varnish\u3092\u518d\u8d77\u52d5\u7121\u3057\u3067\u8a2d\u5b9a\u3092\u9069\u7528\u3059\u308b\u65b9\u6cd5\u4fee\u6b63\u7248\/\"><strong><span style=\"color: #ff0000;\">4\/28\u306b\u4fee\u6b63\u7248\u3092\u30a2\u30c3\u30d7\u3057\u307e\u3057\u305f<\/span><\/strong><\/a><\/p>\n<p><!--more--><strong>\/etc\/init.d\/varnish<\/strong><\/p>\n<p>[code=&#8217;shell&#8217;]<\/p>\n<p>#! \/bin\/sh<br \/>\n#<br \/>\n# varnish Control the varnish HTTP accelerator<br \/>\n#<br \/>\n# chkconfig: &#8211; 90 10<br \/>\n# description: Varnish is a high-perfomance HTTP accelerator<br \/>\n# processname: varnishd<br \/>\n# config: \/etc\/sysconfig\/varnish<br \/>\n# pidfile: \/var\/run\/varnish\/varnishd.pid<\/p>\n<p>### BEGIN INIT INFO<br \/>\n# Provides: varnish<br \/>\n# Required-Start: $network $local_fs $remote_fs<br \/>\n# Required-Stop: $network $local_fs $remote_fs<br \/>\n# Should-Start: $syslog<br \/>\n# Short-Description: start and stop varnishd<br \/>\n# Description: Varnish is a high-perfomance HTTP accelerator<br \/>\n### END INIT INFO<\/p>\n<p># Source function library.<br \/>\n. \/etc\/init.d\/functions<\/p>\n<p>retval=0<br \/>\npidfile=\/var\/run\/varnish.pid<\/p>\n<p>exec=&#8221;\/usr\/sbin\/varnishd&#8221;<br \/>\nprog=&#8221;varnishd&#8221;<br \/>\nconfig=&#8221;\/etc\/sysconfig\/varnish&#8221;<br \/>\nlockfile=&#8221;\/var\/lock\/subsys\/varnish&#8221;<br \/>\n################################<br \/>\nADM=`ps axut | grep varnishd|grep -v grep |head -n 1|sed -e &#8220;s\/$\/ \/g&#8221;|sed -e &#8220;s\/^.\\+-T \\+\\([^ ]\\+\\).\\+$\/\\1\/g&#8221;`<br \/>\nVCL=`ps axut | grep varnishd|grep -v grep |head -n 1|sed -e &#8220;s\/$\/ \/g&#8221;|sed -e &#8220;s\/^.\\+-f \\+\\([^ ]\\+\\).\\+$\/\\1\/g&#8221;`<br \/>\nNOW=`date +%s`<br \/>\n################################<br \/>\n# Include varnish defaults<br \/>\n[ -e \/etc\/sysconfig\/varnish ] &amp;&amp; . \/etc\/sysconfig\/varnish<\/p>\n<p>start() {<\/p>\n<p>\tif [ ! -x $exec ]<br \/>\n\tthen<br \/>\n\t\techo $exec not found<br \/>\n\t\texit 5<br \/>\n\tfi<\/p>\n<p>\tif [ ! -f $config ]<br \/>\n\tthen<br \/>\n\t\techo $config not found<br \/>\n\t\texit 6<br \/>\n\tfi<br \/>\n\techo -n &#8220;Starting varnish HTTP accelerator: &#8221;<\/p>\n<p>\t# Open files (usually 1024, which is way too small for varnish)<br \/>\n\tulimit -n ${NFILES:-131072}<\/p>\n<p>\t# Varnish wants to lock shared memory log in memory.<br \/>\n\tulimit -l ${MEMLOCK:-82000}<\/p>\n<p>\t# $DAEMON_OPTS is set in \/etc\/sysconfig\/varnish. At least, one<br \/>\n\t# has to set up a backend, or \/tmp will be used, which is a bad idea.<br \/>\n\tif [ &#8220;$DAEMON_OPTS&#8221; = &#8220;&#8221; ]; then<br \/>\n\t\techo &#8220;\\$DAEMON_OPTS empty.&#8221;<br \/>\n\t\techo -n &#8220;Please put configuration options in $config&#8221;<br \/>\n\t\treturn 6<br \/>\n\telse<br \/>\n\t\t# Varnish always gives output on STDOUT<br \/>\n\t\tdaemon   $exec -P $pidfile &#8220;$DAEMON_OPTS&#8221; > \/dev\/null 2>&amp;1<br \/>\n\t\tretval=$?<br \/>\n\t\tif [ $retval -eq 0 ]<br \/>\n\t\tthen<br \/>\n\t\t\ttouch $lockfile<br \/>\n\t\t\techo_success<br \/>\n\t\t\techo<br \/>\n\t\telse<br \/>\n\t\t\techo_failure<br \/>\n\t\tfi<br \/>\n\t\treturn $retval<br \/>\n\tfi<br \/>\n}<\/p>\n<p>stop() {<br \/>\n\techo -n &#8220;Stopping varnish HTTP accelerator: &#8221;<br \/>\n\tkillproc $prog<br \/>\n\tretval=$?<br \/>\n\techo<br \/>\n\t[ $retval -eq 0 ] &amp;&amp; rm -f $lockfile<br \/>\n\treturn $retval<br \/>\n}<br \/>\ngraceful() {<br \/>\n\techo reload VCL file: $VCL<br \/>\n\tvarnishadm -T $ADM vcl.load reload$NOW $VCL || error<br \/>\n\tvarnishadm -T $ADM vcl.use reload$NOW || error<br \/>\n\techo Current configs:<br \/>\n\techo_success<br \/>\n\techo<br \/>\n\tvarnishadm -T $ADM vcl.list<br \/>\n}<br \/>\nerror(){<br \/>\n\techo_failure<br \/>\n\techo<br \/>\n\texit 1<br \/>\n}<br \/>\nrestart() {<br \/>\n\tstop<br \/>\n\tstart<br \/>\n}<\/p>\n<p>reload() {<br \/>\n\tgraceful<br \/>\n}<\/p>\n<p>force_reload() {<br \/>\n\trestart<br \/>\n}<\/p>\n<p>rh_status() {<br \/>\n\tstatus $prog<br \/>\n}<\/p>\n<p>rh_status_q() {<br \/>\n\trh_status >\/dev\/null 2>&amp;1<br \/>\n}<\/p>\n<p># See how we were called.<br \/>\ncase &#8220;$1&#8221; in<br \/>\n\tstart)<br \/>\n\t\trh_status_q &amp;&amp; exit 0<br \/>\n\t\t$1<br \/>\n\t\t;;<br \/>\n\tstop)<br \/>\n\t\trh_status_q || exit 0<br \/>\n\t\t$1<br \/>\n\t\t;;<br \/>\n\trestart)<br \/>\n\t\t$1<br \/>\n\t\t;;<br \/>\n\tgraceful)<br \/>\n\t\t$1<br \/>\n\t\t;;<br \/>\n\treload)<br \/>\n\t\t$1<br \/>\n\t\t;;<br \/>\n\tforce-reload)<br \/>\n\t\tforce_reload<br \/>\n\t\t;;<br \/>\n\tstatus)<br \/>\n\t\trh_status<br \/>\n\t\t;;<br \/>\n\tcondrestart|try-restart)<br \/>\n\t\trh_status_q || exit 0<br \/>\n\t\trestart<br \/>\n\t\t;;<br \/>\n\t*)<br \/>\n\techo &#8220;Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|graceful|force-reload}&#8221;<\/p>\n<p>\texit 2<br \/>\nesac<\/p>\n<p>exit $?<br \/>\n[\/code]<\/p>\n<h4>\u5143\u30d5\u30a1\u30a4\u30eb\u3068\u306eDIFF<\/h4>\n<p>[code=&#8217;plain&#8217;]<br \/>\n[root@LIP-APP-01 ~]# diff \/etc\/init.d\/varnish varnish<br \/>\n30,34c30<br \/>\n< ################################\n< ADM=`ps axut | grep varnishd|grep -v grep |head -n 1|sed -e \"s\/$\/ \/g\"|sed -e \"s\/^.\\+-T \\+\\([^ ]\\+\\).\\+$\/\\1\/g\"`\n< VCL=`ps axut | grep varnishd|grep -v grep |head -n 1|sed -e \"s\/$\/ \/g\"|sed -e \"s\/^.\\+-f \\+\\([^ ]\\+\\).\\+$\/\\1\/g\"`\n< NOW=`date +%s`\n< ################################\n---\n><br \/>\n90,103c86<br \/>\n< graceful() {\n<       echo reload VCL file: $VCL\n<       varnishadm -T $ADM vcl.load reload$NOW $VCL || error\n<       varnishadm -T $ADM vcl.use reload$NOW || error\n<       echo Current configs:\n<       echo_success\n<       echo\n<       varnishadm -T $ADM vcl.list\n< }\n< error(){\n<       echo_failure\n<       echo\n<       exit 1\n< }\n---\n><br \/>\n110c93<br \/>\n<       graceful\n---\n>       restart<br \/>\n138,140d120<br \/>\n<       graceful)\n<               $1\n<               ;;\n141a122\n>               rh_status_q || exit 7<br \/>\n155c136<br \/>\n<       echo \"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|graceful|force-reload}\"\n---\n>       echo &#8220;Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload}&#8221;<br \/>\n[\/code]<\/p>\n<p>\u3053\u308c\u3067<br \/>\n\/etc\/init.d\/varnish graceful<br \/>\n\u3092\u3059\u308b\u3053\u3068\u3067\u3044\u307e\u8aad\u307f\u8fbc\u3093\u3067\u308b\u8a2d\u5b9a\u30d5\u30a1\u30a4\u30eb\u3092\u518d\u8aad\u307f\u8fbc\u307f\u3057\u307e\u3059<\/p>\n<h4>\u5b9f\u884c\u7d50\u679c<\/h4>\n<p>[code=&#8217;shell&#8217;]<br \/>\n[root@LIP-APP-01 ~]# date;ps axut | grep varnish;\/etc\/init.d\/varnish reload;ps axut | grep varnish<br \/>\n2010\u5e74  4\u6708 27\u65e5 \u706b\u66dc\u65e5 20:45:04 JST<br \/>\nroot     27984  0.0  0.1 106492  1096 ?        Ss   20:43   0:00 \/usr\/sbin\/varnishd -P \/var\/run\/varnish.pid -a :80 -T 192.168.1.123:6082 -f \/etc\/varnish\/default.vcl -u varnish -g varnish -s malloc,700M<br \/>\nvarnish  27985  0.0  0.3 281728  3604 ?        Sl   20:43   0:00 \/usr\/sbin\/varnishd -P \/var\/run\/varnish.pid -a :80 -T 192.168.1.123:6082 -f \/etc\/varnish\/default.vcl -u varnish -g varnish -s malloc,700M<br \/>\nroot     28135  0.0  0.0  65368   828 pts\/0    S+   20:45   0:00 grep varnish<br \/>\nreload VCL file: \/etc\/varnish\/default.vcl<br \/>\nVCL compiled.<\/p>\n<p>Current configs:<br \/>\n                                                           [  OK  ]<br \/>\navailable       0 boot<br \/>\navailable       0 reload1272368689<br \/>\navailable       1 reload1272368699<br \/>\nactive          0 reload1272368704<\/p>\n<p>root     27984  0.0  0.1 106492  1100 ?        Ss   20:43   0:00 \/usr\/sbin\/varnishd -P \/var\/run\/varnish.pid -a :80 -T 192.168.1.123:6082 -f \/etc\/varnish\/default.vcl -u varnish -g varnish -s malloc,700M<br \/>\nvarnish  27985  0.0  0.3 283796  3620 ?        Sl   20:43   0:00 \/usr\/sbin\/varnishd -P \/var\/run\/varnish.pid -a :80 -T 192.168.1.123:6082 -f \/etc\/varnish\/default.vcl -u varnish -g varnish -s malloc,700M<br \/>\nroot     28164  0.0  0.0  65368   836 pts\/0    S+   20:45   0:00 grep varnish<br \/>\n[root@LIP-APP-01 ~]#<br \/>\n[\/code]<\/p>\n<h4>\u5931\u6557\u306e\u5834\u5408\u3082\u30d7\u30ed\u30bb\u30b9\u306f\u6b7b\u3093\u3067\u306a\u3044<\/h4>\n<p>[code=&#8217;shell&#8217;]<br \/>\n[root@LIP-APP-01 ~]# date;ps axut | grep varnish;\/etc\/init.d\/varnish reload;ps axut | grep varnish<br \/>\n2010\u5e74  4\u6708 27\u65e5 \u706b\u66dc\u65e5 20:47:05 JST<br \/>\nroot     27984  0.0  0.1 106492  1100 ?        Ss   20:43   0:00 \/usr\/sbin\/varnishd -P \/var\/run\/varnish.pid -a :80 -T 192.168.1.123:6082 -f \/etc\/varnish\/default.vcl -u varnish -g varnish -s malloc,700M<br \/>\nvarnish  27985  0.0  0.3 283796  3620 ?        Sl   20:43   0:00 \/usr\/sbin\/varnishd -P \/var\/run\/varnish.pid -a :80 -T 192.168.1.123:6082 -f \/etc\/varnish\/default.vcl -u varnish -g varnish -s malloc,700M<br \/>\nroot     28241  0.0  0.0  65368   832 pts\/0    S+   20:47   0:00 grep varnish<br \/>\nreload VCL file: \/etc\/varnish\/default.vcl<br \/>\nCommand failed with error code 106<br \/>\n                                                           [\u5931\u6557]<br \/>\nroot     27984  0.0  0.1 106492  1100 ?        Ss   20:43   0:00 \/usr\/sbin\/varnishd -P \/var\/run\/varnish.pid -a :80 -T 192.168.1.123:6082 -f \/etc\/varnish\/default.vcl -u varnish -g varnish -s malloc,700M<br \/>\nvarnish  27985  0.0  0.3 283796  3620 ?        Sl   20:43   0:00 \/usr\/sbin\/varnishd -P \/var\/run\/varnish.pid -a :80 -T 192.168.1.123:6082 -f \/etc\/varnish\/default.vcl -u varnish -g varnish -s malloc,700M<br \/>\nroot     28263  0.0  0.0  65368   836 pts\/0    S+   20:47   0:00 grep varnish<br \/>\n[root@LIP-APP-01 ~]#<br \/>\n[\/code]<\/p>\n<p>\u898b\u3066\u3082\u3089\u3048\u3070\u308f\u304b\u308b\u3068\u304a\u3082\u3046\u306e\u3067\u3059\u304c<br \/>\n\u52d5\u304f\u306e\u304c\u7b2c\u4e00\u76ee\u7684\u3060\u3063\u305f\u305f\u3081PORT\u306e\u53d6\u5f97\u3068\u304b\u3092\u304b\u306a\u308a\u5f37\u5f15\u306a\u65b9\u6cd5(grep\u3068\u304b\u306e\u3042\u308f\u305b\u6280)\u3067\u3084\u308a\u307e\u3057\u305f\u306e\u3067\uff08\u30c7\u30d5\u30a9\u30eb\u30c8\u306esysconfig\u3067\u3044\u3051\u305f\u3089\u3044\u3044\u306a\u3068\u304a\u3082\u3063\u305f\u306e\u3067\u30fb\u30fb\u30fb\uff09<br \/>\n\u4e0d\u5177\u5408\u3068\u304b\u51fa\u305f\u3089\u6559\u3048\u3066\u3082\u3089\u3048\u308b\u3068\u3042\u308a\u304c\u305f\u3044\u306a\u30fc\u3068<\/p>\n<hr>\n<h4>\u53c2\u8003\u30b5\u30a4\u30c8<\/h4>\n<p><a target='_blank' href=\"http:\/\/kristian.blog.linpro.no\/2009\/02\/18\/easy-reloading-of-varnish-vcl\/\">Easy reloading of varnish\u2019 VCL<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Varnish\u3067\u518d\u8d77\u52d5\u3092\u4f34\u308f\u305a\u306b\u8a2d\u5b9a\u306e\u518d\u8aad\u8fbc\u3092\u884c\u3044\u305f\u3044\u3068\u304d\u306fvarnishadm\u304btelnet\u3067\u5165\u3063\u3066\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u611f\u3058\u3067\u30b3\u30de\u30f3\u30c9\u3092\u6253\u305f\u306a\u3044\u3068\u3044\u3051\u307e\u305b\u3093 [code=&#8217;plain&#8217;] varnish <a href='https:\/\/blog.xcir.net\/?p=124' class='excerpt-more'>[&#8230;]<\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[5],"class_list":["post-124","post","type-post","status-publish","format-standard","hentry","category-3","tag-varnish","category-3-id","post-seq-1","post-parity-odd","meta-position-corners","fix"],"_links":{"self":[{"href":"https:\/\/blog.xcir.net\/index.php?rest_route=\/wp\/v2\/posts\/124","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.xcir.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.xcir.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.xcir.net\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.xcir.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=124"}],"version-history":[{"count":12,"href":"https:\/\/blog.xcir.net\/index.php?rest_route=\/wp\/v2\/posts\/124\/revisions"}],"predecessor-version":[{"id":133,"href":"https:\/\/blog.xcir.net\/index.php?rest_route=\/wp\/v2\/posts\/124\/revisions\/133"}],"wp:attachment":[{"href":"https:\/\/blog.xcir.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=124"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.xcir.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=124"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.xcir.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=124"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}