Skip to content

Commit

Permalink
parse -v/-h flags first and announce custom log tails in verbose mode
Browse files Browse the repository at this point in the history
  • Loading branch information
dzuelke committed Aug 30, 2014
1 parent e2262b1 commit fb3a1a7
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 32 deletions.
26 changes: 18 additions & 8 deletions bin/heroku-hhvm-apache2
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,23 @@ export PORT=${PORT:-$(( $RANDOM+1024 ))}
# our standard logs
logs=( "/tmp/heroku.apache2_error.$PORT.log" "/tmp/heroku.apache2_access.$PORT.log" )

while getopts ":C:c:i:l:vh" opt; do
optstring=":C:c:i:l:vh"

# process flags first
while getopts "$optstring" opt; do
case $opt in
v)
verbose=1
;;
h)
print_help 2>&1
exit
;;
esac
done

OPTIND=1 # start over with options parsing
while getopts "$optstring" opt; do
case $opt in
C)
httpd_config_include=$(check_exists "$OPTARG" "C")
Expand All @@ -114,16 +130,10 @@ while getopts ":C:c:i:l:vh" opt; do
exit 1
fi
touch_log "$logfile" || { echo "Could not touch '$logfile'; permissions problem?" >&2; exit 1; }
[[ $verbose ]] && echo "Tailing '$logfile' to stderr" >&2
logs+=("$logfile") # must quote here in case a wildcard matched a file with a space in the name
done
;;
v)
verbose=1
;;
h)
print_help 2>&1
exit
;;
\?)
echo "Invalid option: -$OPTARG" >&2
exit 2
Expand Down
26 changes: 18 additions & 8 deletions bin/heroku-hhvm-nginx
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,23 @@ export PORT=${PORT:-$(( $RANDOM+1024 ))}
# our standard logs
logs=( "/tmp/heroku.nginx_access.$PORT.log" )

while getopts ":C:c:i:l:vh" opt; do
optstring=":C:c:i:l:vh"

# process flags first
while getopts "$optstring" opt; do
case $opt in
v)
verbose=1
;;
h)
print_help 2>&1
exit
;;
esac
done

OPTIND=1 # start over with options parsing
while getopts "$optstring" opt; do
case $opt in
C)
nginx_config_include=$(check_exists "$OPTARG" "C")
Expand All @@ -115,16 +131,10 @@ while getopts ":C:c:i:l:vh" opt; do
exit 1
fi
touch_log "$logfile" || { echo "Could not touch '$logfile'; permissions problem?" >&2; exit 1; }
[[ $verbose ]] && echo "Tailing '$logfile' to stderr" >&2
logs+=("$logfile") # must quote here in case a wildcard matched a file with a space in the name
done
;;
v)
verbose=1
;;
h)
print_help 2>&1
exit
;;
\?)
echo "Invalid option: -$OPTARG" >&2
exit 2
Expand Down
26 changes: 18 additions & 8 deletions bin/heroku-php-apache2
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,23 @@ export PORT=${PORT:-$(( $RANDOM+1024 ))}
# our standard logs
logs=( "/tmp/heroku.php-fpm.$PORT.log" "/tmp/heroku.apache2_error.$PORT.log" "/tmp/heroku.apache2_access.$PORT.log" )

while getopts ":C:c:F:f:i:l:vh" opt; do
optstring=":C:c:F:f:i:l:vh"

# process flags first
while getopts "$optstring" opt; do
case $opt in
v)
verbose=1
;;
h)
print_help 2>&1
exit
;;
esac
done

OPTIND=1 # start over with options parsing
while getopts "$optstring" opt; do
case $opt in
C)
httpd_config_include=$(check_exists "$OPTARG" "C")
Expand Down Expand Up @@ -127,16 +143,10 @@ while getopts ":C:c:F:f:i:l:vh" opt; do
exit 1
fi
touch_log "$logfile" || { echo "Could not touch '$logfile'; permissions problem?" >&2; exit 1; }
[[ $verbose ]] && echo "Tailing '$logfile' to stderr" >&2
logs+=("$logfile") # must quote here in case a wildcard matched a file with a space in the name
done
;;
v)
verbose=1
;;
h)
print_help 2>&1
exit
;;
\?)
echo "Invalid option: -$OPTARG" >&2
exit 2
Expand Down
26 changes: 18 additions & 8 deletions bin/heroku-php-nginx
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,23 @@ export PORT=${PORT:-$(( $RANDOM+1024 ))}
# our standard logs
logs=( "/tmp/heroku.php-fpm.$PORT.log" "/tmp/heroku.nginx_access.$PORT.log" )

while getopts ":C:c:F:f:i:l:vh" opt; do
optstring=":C:c:F:f:i:l:vh"

# process flags first
while getopts "$optstring" opt; do
case $opt in
v)
verbose=1
;;
h)
print_help 2>&1
exit
;;
esac
done

OPTIND=1 # start over with options parsing
while getopts "$optstring" opt; do
case $opt in
C)
nginx_config_include=$(check_exists "$OPTARG" "C")
Expand Down Expand Up @@ -128,16 +144,10 @@ while getopts ":C:c:F:f:i:l:vh" opt; do
exit 1
fi
touch_log "$logfile" || { echo "Could not touch '$logfile'; permissions problem?" >&2; exit 1; }
[[ $verbose ]] && echo "Tailing '$logfile' to stderr" >&2
logs+=("$logfile") # must quote here in case a wildcard matched a file with a space in the name
done
;;
v)
verbose=1
;;
h)
print_help 2>&1
exit
;;
\?)
echo "Invalid option: -$OPTARG" >&2
exit 2
Expand Down

0 comments on commit fb3a1a7

Please sign in to comment.