Commits

Louis Opter  committed 92e0843

Add a little "enqueue" script that uses curl to create a lot of jobs at once

  • Participants
  • Parent commits 80a184d

Comments (0)

Files changed (1)

+#!/usr/bin/env bash
+
+# Little script to enqueue tons of jobs on the application
+
+if [ "$1" = "--help" ] || [ "$1" = "-h" ] ; then
+    echo "Usage: $0 [url] [queue_name] [number_of_jobs]"
+    exit
+fi
+
+url=${1:-"http://php-resque.dotcloudapp.com/editor"}
+queue=${2:-default}
+number=${3:-10}
+csrf_token=4a42d1031ffb6cae2d5a9da00ffad955
+
+if [ `basename $url` != "editor" ] ; then
+    url="$url/editor"
+fi
+
+echo -e "\033[1;34m-->\033[0m http://php-resque.dotcloudapp.com/panel"
+echo -e "\033[1;34m-->\033[0m Queue: $queue"
+echo -e "\033[1;34m-->\033[0m Number of jobs: $number"
+
+for ((i = 4 + $number ; i >= 0 ; i = i - 1)) ; do
+    echo -n ' '
+done
+
+echo -ne "\033[1;31m]\r\033[1;34m--> \033[1;31m[\033[0m"
+
+for ((i = 0 ; i != number ; i = i + 1)) ; do
+    curl $url                           \
+        -b "ci_csrf_token=$csrf_token"  \
+        -F "ci_csrf_token=$csrf_token"  \
+        -F "job_name=hammer-$i"         \
+        -F "queue_name=$queue"          \
+        -F "submit=Enqueue"
+    echo -n '#'
+done
+
+echo