Ticket #35863: 20121231-varnish-startup.patch
File 20121231-varnish-startup.patch, 5.2 KB (added by robsonpeixoto@…, 12 years ago) |
---|
-
Portfile
1 1 # $Id$ 2 2 3 PortSystem 3 PortSystem 1.0 4 4 5 name varnish 6 epoch 20110709 7 version 3.0.3 8 categories www 9 platforms darwin 10 maintainers pmq openmaintainer 5 name varnish 6 epoch 20110709 7 version 3.0.3 8 revision 1 9 categories www 10 platforms darwin 11 maintainers pmq openmaintainer 11 12 12 description 13 long_description 14 13 description Varnish is a state-of-the-art, high-performance HTTP accelerator 14 long_description Varnish was written from the ground up to be a high \ 15 performance caching reverse proxy. 15 16 16 homepage 17 master_sites 17 homepage http://www.varnish-cache.org 18 master_sites http://repo.varnish-cache.org/source/ 18 19 19 checksums 20 20 checksums rmd160 a911a2637ef26607aad8a1c34a83bc797a15235d \ 21 sha256 2d37d18d952f58b208ac3a0706d4d3e4c0de304b1fcc9df5019571c75f148ab2 21 22 22 depends_build 23 depends_build port:pkgconfig 23 24 24 depends_lib port:pcre 25 depends_lib port:pcre 26 27 startupitem.create yes 28 startupitem.start "${prefix}/share/${name}/varnish.init start" 29 startupitem.stop "${prefix}/share/${name}/varnish.init stop" 30 31 post-destroot { 32 # create dir 33 xinstall -d -m 755 ${destroot}${prefix}/share/${name} 34 35 # copy files 36 xinstall -m 644 ${filespath}/varnish.conf.in ${destroot}${prefix}/etc/${name}/varnish.conf.default 37 xinstall -m 755 ${filespath}/varnish.init.in ${destroot}${prefix}/share/${name}/${name}.init 38 xinstall -m 755 ${filespath}/varnish-vcl-reload.in ${destroot}${prefix}/sbin/varnish-vcl-reload 39 40 # replace @PREFIX@ to ${prefix} 41 reinplace "s|@PREFIX@|${prefix}|g" \ 42 ${destroot}${prefix}/etc/${name}/varnish.conf.default \ 43 ${destroot}${prefix}/share/${name}/${name}.init \ 44 ${destroot}${prefix}/sbin/varnish-vcl-reload 45 46 file rename ${destroot}${prefix}/etc/${name}/default.vcl ${destroot}${prefix}/etc/${name}/default.vcl.default 47 } 48 49 post-activate { 50 if {![file exists ${prefix}/etc/${name}/default.vcl]} { 51 file copy ${prefix}/etc/${name}/default.vcl.default \ 52 ${prefix}/etc/${name}/default.vcl 53 } 54 if {![file exists ${prefix}/etc/${name}/varnish.conf]} { 55 file copy ${prefix}/etc/${name}/varnish.conf.default \ 56 ${prefix}/etc/${name}/varnish.conf 57 } 58 59 # dirs nedded to run varnish 60 xinstall -d -m 755 -o nobody -g nobody ${prefix}/var/${name} 61 xinstall -d -m 755 -o nobody -g nobody ${prefix}/var/run/${name} 62 } 63 64 livecheck.url ${master_sites} 65 livecheck.type regex 66 livecheck.regex ${name}-(\\d+\\.\\d+\\.\\d+).tar.gz -
files/varnish-vcl-reload.in
1 #!/bin/sh 2 3 cfg=${1:-@PREFIX@/etc/varnish/default.vcl} 4 if [ ! -e "$cfg" ]; then 5 printf 'ERROR: VCL file %s does not exist\n' "$cfg" >&2 6 exit 1 7 fi 8 9 activecfg=$(varnishadm 'vcl.list' | awk '/active/ { print $3 }') 10 if [ -z "$activecfg" ]; then 11 printf 'ERROR: No active VCL found!\n' >&2 12 exit 1 13 fi 14 15 newcfg=$(date +'vcl-%s') 16 printf 'INFO: using new config %s\n' "$cfg" 17 18 varnishadm "vcl.load $newcfg $cfg" && 19 varnishadm "vcl.use $newcfg" && 20 varnishadm "vcl.discard $activecfg" -
files/varnish.conf.in
1 # 2 # MANDATORIES command line options to varnishd 3 # 4 5 VARNISH_CFG="@PREFIX@/etc/varnish/default.vcl" 6 VARNISHD_PID="@PREFIX@/var/run/varnish/varnish.pid" 7 8 VARNISHD_OPTS="-a 0.0.0.0:80 \ 9 -f $VARNISH_CFG \ 10 -T localhost:6082 \ 11 -P $VARNISHD_PID \ 12 -s malloc,64M 13 -u nobody -g nobody" -
files/varnish.init.in
1 #!/bin/bash 2 3 . @PREFIX@/etc/varnish/varnish.conf 4 5 if [[ -r $VARNISHD_PID ]]; then 6 read -r PID < "$VARNISHD_PID" 7 ps -p $PID &> /dev/null 8 CHECK=$? 9 if [[ "x$CHECK" == "x1" ]]; then 10 unset PID 11 rm -f "$VARNISHD_PID" 12 fi 13 fi 14 15 case $1 in 16 start) 17 @PREFIX@/sbin/varnishd $VARNISHD_OPTS 18 ;; 19 stop) 20 [[ $PID ]] && kill $PID &>/dev/null 21 ;; 22 restart) 23 $0 stop 24 sleep 1 25 $0 start 26 ;; 27 reload) 28 @PREFIX@/sbin/varnish-vcl-reload $VARNISH_CFG 29 ;; 30 *) 31 echo "usage: $0 {start|stop|restart|reload}" 32 ;; 33 esac