Ticket #35863: 3.0.3-startupitem-reloadscript.patch​

File 3.0.3-startupitem-reloadscript.patch​, 5.8 KB (added by robsonpeixoto@…, 12 years ago)

V2 - A lot of new things. A status script, a reload script and startupitem

Line 
1Index: Portfile
2===================================================================
3--- Portfile    (revision 97329)
4+++ Portfile    (working copy)
5@@ -1,25 +1,65 @@
6 # $Id$
7 
8-PortSystem           1.0
9+PortSystem                             1.0
10 
11-name                 varnish
12-epoch                 20110709
13-version                      3.0.2
14-revision              1
15-categories           www
16-platforms            darwin
17-maintainers          pmq openmaintainer
18+name                                   varnish
19+epoch                                  20120820
20+version                                        3.0.3
21+revision                               0
22+categories                             www
23+platforms                              darwin
24+maintainers                            pmq openmaintainer
25 
26-description          Varnish is a state-of-the-art, high-performance HTTP accelerator
27-long_description      Varnish was written from the ground up to be a high \
28-                     performance caching reverse proxy.
29+description                            Varnish is a state-of-the-art, high-performance HTTP accelerator
30+long_description               Varnish was written from the ground up to be a high \
31+                                               performance caching reverse proxy.
32 
33-homepage             http://www.varnish-cache.org
34-master_sites         http://repo.varnish-cache.org/source/
35+homepage                               http://www.varnish-cache.org
36+master_sites                   http://repo.varnish-cache.org/source/
37 
38-checksums            sha1 906f1536cb7e728d18d9425677907ae723943df7 \
39-                     rmd160 6093839815ba72107fa2b52f0a198167a3a6b79b
40+checksums                              rmd160 a911a2637ef26607aad8a1c34a83bc797a15235d \
41+                                               sha256 2d37d18d952f58b208ac3a0706d4d3e4c0de304b1fcc9df5019571c75f148ab2
42 
43-depends_build         port:pkgconfig
44+depends_build                  port:pkgconfig
45 
46-depends_lib           port:pcre
47+depends_lib                            port:pcre
48+
49+startupitem.create      yes
50+startupitem.start              "${prefix}/sbin/varnish-server start"
51+startupitem.stop               "${prefix}/sbin/varnish-server stop"
52+startupitem.restart            "${prefix}/sbin/varnish-server restart"
53+
54+post-build {
55+       copy ${filespath}/varnish-server.in ${workpath}/varnish-server
56+       copy ${filespath}/varnish-vcl-reload.in ${workpath}/varnish-vcl-reload
57+       copy ${filespath}/varnish-server.conf.in ${workpath}/varnish-server.conf.default       
58+       
59+    reinplace "s|@PREFIX@|${prefix}|g" \
60+        ${workpath}/varnish-server \
61+        ${workpath}/varnish-vcl-reload \
62+               ${workpath}/varnish-server.conf.default
63+}
64+
65+post-destroot {
66+       move ${destroot}${prefix}/etc/varnish/default.vcl ${destroot}${prefix}/etc/varnish/default.vcl.default
67+       
68+       xinstall -m 755 ${workpath}/varnish-server ${destroot}${prefix}/sbin/varnish-server
69+       xinstall -m 755 ${workpath}/varnish-vcl-reload ${destroot}${prefix}/bin/varnish-vcl-reload
70+       xinstall -m 644 ${workpath}/varnish-server.conf.default ${destroot}${prefix}/etc/varnish/varnish-server.conf.default
71+}
72+
73+post-activate {
74+    if {![file exists ${prefix}/etc/varnish/varnish-server.conf]} {
75+        file copy ${prefix}/etc/varnish/varnish-server.conf.default \
76+            ${prefix}/etc/varnish/varnish-server.conf
77+    }
78+    if {![file exists ${prefix}/etc/varnish/default.vcl]} {
79+        file copy ${prefix}/etc/varnish/default.vcl.default \
80+            ${prefix}/etc/varnish/default.vcl
81+    }
82+    xinstall -m 755 -d ${prefix}/var/varnish/
83+}
84+
85+livecheck.url                  ${master_sites}
86+livecheck.type                 regex
87+livecheck.regex                        varnish-(\\d+\\.\\d+\\.\\d+).tar.gz
88Index: files/varnish-server.conf.in
89===================================================================
90--- files/varnish-server.conf.in        (revision 0)
91+++ files/varnish-server.conf.in        (working copy)
92@@ -0,0 +1,13 @@
93+# Command line options to varnishd
94+# based on https://projects.archlinux.org/svntogit/packages.git/tree/trunk?h=packages/varnish
95+
96+VARNISH_CFG="@PREFIX@/etc/varnish/default.vcl"
97+
98+VARNISH_PID="@PREFIX@/var/run/varnishd.pid"
99+
100+VARNISHD_OPTS="-a 0.0.0.0:80 \
101+                          -f $VARNISH_CFG \
102+                          -T localhost:6082 \
103+                          -P $VARNISH_PID \
104+                          -s malloc,64M \
105+                          -u nobody -g nobody"
106Index: files/varnish-server.in
107===================================================================
108--- files/varnish-server.in     (revision 0)
109+++ files/varnish-server.in     (working copy)
110@@ -0,0 +1,43 @@
111+#!/bin/bash
112+
113+. @PREFIX@/etc/varnish/varnish-server.conf
114+
115+pidfile=$VARNISH_PID
116+if [[ -r $pidfile ]]; then
117read -r PID < "$pidfile"
118+  ps -p $PID 2&> /dev/null
119if [[ $? != 0 ]]; then
120+    # stale pidfile
121+    unset PID
122+    rm -f "$pidfile"
123fi
124+fi
125+
126+case $1 in
127+  start)
128+    if /opt/local/sbin/varnishd $VARNISHD_OPTS; then
129+    exit 0
130+    else
131+      echo "Varnish start FAIL"
132+      exit 1
133+    fi
134+    ;;
135+  stop)
136+    if [[ $PID ]] && kill $PID &>/dev/null; then
137+      exit 0
138+    else
139+      exit 1
140+    fi
141+    ;;
142+  restart)
143+    $0 stop
144+    sleep 1
145+    $0 start
146+    ;;
147+  reload)
148+    status "Recompiling and Reloading VCL" varnish-vcl-reload $VARNISH_CFG
149+    ;;
150+  *)
151+    echo "usage: $0 {start|stop|restart|reload}"
152;;
153+esac
154
155Property changes on: files/varnish-server.in
156___________________________________________________________________
157Added: svn:executable
158## -0,0 +1 ##
159+*
160\ No newline at end of property
161Index: files/varnish-vcl-reload.in
162===================================================================
163--- files/varnish-vcl-reload.in (revision 0)
164+++ files/varnish-vcl-reload.in (working copy)
165@@ -0,0 +1,21 @@
166+#!/bin/sh
167+# based on https://projects.archlinux.org/svntogit/packages.git/tree/trunk?h=packages/varnish
168+
169+cfg=${1:-@PREFIX@/etc/varnish/default.vcl}
170+if [ ! -e "$cfg" ]; then
171printf 'ERROR: VCL file %s does not exist\n' "$cfg" >&2
172exit 1
173+fi
174+
175+activecfg=$(varnishadm 'vcl.list' | awk '/active/ { print $3 }')
176+if [ -z "$activecfg" ]; then
177printf 'ERROR: No active VCL found!\n' >&2
178exit 1
179+fi
180+
181+newcfg=$(date +'vcl-%s')
182+printf 'INFO: using new config %s\n' "$cfg"
183+
184+varnishadm "vcl.load $newcfg $cfg" &&
185+varnishadm "vcl.use $newcfg" &&
186+varnishadm "vcl.discard $activecfg"
187
188Property changes on: files/varnish-vcl-reload.in
189___________________________________________________________________
190Added: svn:executable
191## -0,0 +1 ##
192+*
193\ No newline at end of property