Repository: trafficserver Updated Branches: refs/heads/master 3e64d405c -> cdd1d15b4
TS-3139] New script, traffic_primer, to prime a set of boxes with content Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/cdd1d15b Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/cdd1d15b Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/cdd1d15b Branch: refs/heads/master Commit: cdd1d15b48fe94158a59454ef75233f1ee827172 Parents: 3e64d40 Author: Leif Hedstrom <[email protected]> Authored: Wed Oct 15 14:47:01 2014 -0600 Committer: Leif Hedstrom <[email protected]> Committed: Wed Oct 15 14:47:01 2014 -0600 ---------------------------------------------------------------------- CHANGES | 4 +++ tools/traffic_primer | 79 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 83 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/trafficserver/blob/cdd1d15b/CHANGES ---------------------------------------------------------------------- diff --git a/CHANGES b/CHANGES index 100261c..a7b3d0c 100644 --- a/CHANGES +++ b/CHANGES @@ -1,6 +1,10 @@ -*- coding: utf-8 -*- Changes with Apache Traffic Server 5.2.0 + *) [TS-3139] New script, traffic_primer, which will fetch a URL from origin + (or another proxy) and PUSH the same object to a given set of + caches. Useful for priming a pool of servers with the same object. + *) [TS-3135] Disable SSLv3 by default. This can be enabled again by adding a line to records.config for proxy.config.ssl.SSLv3. http://git-wip-us.apache.org/repos/asf/trafficserver/blob/cdd1d15b/tools/traffic_primer ---------------------------------------------------------------------- diff --git a/tools/traffic_primer b/tools/traffic_primer new file mode 100755 index 0000000..1a39de7 --- /dev/null +++ b/tools/traffic_primer @@ -0,0 +1,79 @@ +#!/bin/sh +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Simple script to fetch a URL through one proxy, and then PUSH that response (headers +# and body) to a set of hosts. The host:port defaults to localhost:80 for fetching +# the URL, but can be overriden with -h/-p. + + +# Print some help text +usage() { + echo 'Usage: traffic_primer -u <url> [-h Host] [-p port] host1 host2 ...' + exit 2 +} + +# Default values for command line options +url="" +host="localhost" +port="80" + +# Parse command line arguments +PARGS=$(getopt u:h:p: $@) +[ $? != 0 ] && usage + +set -- $PARGS +while true; do + case "$1" in + -u) + url="$2" + shift 2 ;; + -h) + host="$2" + shift 2 ;; + -p) + port="$2" + shift 2 ;; + --) + shift + break ;; + *) + usage + break + ;; + esac +done + +[ "" == "$url" ] && usage + +tmpfile=$(mktemp /tmp/pusher-XXXXXX) + +# CLeanup just in case +trap "rm -f $tmpfile; exit 0" 0 1 2 3 15 + +# Fetch the URL through the proxy on localhost, and create the file for PUSH +curl -x ${host}:${port} -s -i -o ${tmpfile} $url + +for h in $@; do + curl -f -I -x ${h}:${port} -s -o /dev/null -H "Cache-Control: only-if-cached" $url > /dev/null + if [ $? -gt 0 ]; then + echo "PUSHing to $h..." + curl -x ${h}:80 -s -o /dev/null -X PUSH --data-binary @${tmpfile} $url + fi +done + +rm -f ${tmpfile}
