21
by Kapil Thangavelu
add ctl scripts |
1 |
#!/bin/bash
|
145.1.1
by Abel Deuring
more copyright notcies added. |
2 |
|
3 |
# Copyright 2012, 2013 Marco Ceppi, Canonical Ltd. This software is
|
|
4 |
# licensed under the GNU Affero General Public License version 3 (see
|
|
5 |
# the file LICENSE).
|
|
6 |
||
97.1.1
by Aaron Bentley
Tweak scripts, makefile to support charm. |
7 |
: ${PROJECT_DIR:=$HOME/charmworld} |
189.3.1
by Curtis Hovey
Quick draft of poll to release port. |
8 |
: ${INI:=$PROJECT_DIR/production.ini} |
9 |
||
10 |
paster="$PROJECT_DIR/bin/paster" |
|
11 |
output=$($paster serve --stop-daemon --pid-file=$HOME/var/appserver.pid) |
|
189.3.3
by Curtis Hovey
Must provide a string. |
12 |
[ -n "$output" ] && echo "$output" |
189.3.1
by Curtis Hovey
Quick draft of poll to release port. |
13 |
|
14 |
port=$(sed -e '/\[server:main\]/,/port *=/!d; /port *=/!d; s/port *= *//' $INI) |
|
15 |
called=0 |
|
16 |
while [ -n "$(exec 6<>/dev/tcp/127.0.0.1/$port && echo held)" ]; do |
|
17 |
if [ $((called)) -eq 300 ]; then |
|
18 |
echo "Port $port held for more than 5 minutes." |
|
19 |
break
|
|
20 |
fi
|
|
21 |
called=$((called+1)) |
|
22 |
sleep 1
|
|
23 |
done
|
|
24 |
if [ $((called)) -ne 300 ]; then |
|
25 |
echo "Port $port released after $called seconds." |
|
26 |
fi
|