Skip to content
Permalink
Browse files

Ability to run twistd with profiling enabled

  • Loading branch information...
dreid committed Apr 12, 2007
1 parent 3e62ae3 commit 3df956adaedda9646458e7f5c8b90bae915f49cb
Showing with 13 additions and 6 deletions.
  1. +6 −3 bin/caldavd
  2. +7 −3 run
@@ -28,6 +28,7 @@ configfile="";
twistdpath="$(type -p twistd)";
plugin_name="caldav";
service_type="";
profile="";

py_version ()
{
@@ -79,7 +80,7 @@ usage ()

if [ "${1--}" != "-" ]; then echo "$@"; echo; fi;

echo "Usage: ${program} [-hX] [-u username] [-g groupname] [-T twistd] [-t type] [-f caldavd.plist]";
echo "Usage: ${program} [-hX] [-u username] [-g groupname] [-T twistd] [-t type] [-f caldavd.plist] [-p statsfile]";
echo "Options:";
echo " -h Print this help and exit";
echo " -X Do not daemonize";
@@ -88,12 +89,13 @@ usage ()
echo " -f Configuration file to read";
echo " -T Path to twistd binary";
echo " -t Process type (Master, Slave or Combined)";
echo " -p Path to the desired pstats file.";

if [ "${1-}" == "-" ]; then return 0; fi;
exit 64;
}

while getopts 'hXu:g:f:T:P:t:' option; do
while getopts 'hXu:g:f:T:P:t:p:' option; do
case "${option}" in
'?') usage; ;;
'h') usage -; exit 0; ;;
@@ -104,6 +106,7 @@ while getopts 'hXu:g:f:T:P:t:' option; do
'g') groupname="-g ${OPTARG}"; ;;
'P') plugin_name="${OPTARG}"; ;;
't') service_type="-o ProcessType=${OPTARG}"; ;;
'p') profile="--profile=${OPTARG} --nothotshot --savestats"; ;;
esac;
done;

@@ -113,4 +116,4 @@ if [ $# != 0 ]; then usage "Unrecognized arguments:" "$@"; fi;

export PYTHONPATH

exec "${python}" "${twistdpath}" ${daemonize} ${username} ${groupname} "${plugin_name}" ${configfile} ${service_type};
exec "${python}" "${twistdpath}" ${daemonize} ${username} ${groupname} ${profile} "${plugin_name}" ${configfile} ${service_type};
10 run
@@ -39,14 +39,15 @@ disable_setup="false";
plugin_name="caldav";
service_type="Combined";
read_key="";
profile="";

usage ()
{
program="$(basename "$0")";

if [ "${1--}" != "-" ]; then echo "$@"; echo; fi;

echo "Usage: ${program} [-hvsfpndkr] [-K key] [-iI dst] [-t type]";
echo "Usage: ${program} [-hvsfpndkr] [-K key] [-iI dst] [-t type] [-S statsfile]";
echo "Options:";
echo " -h Print this help and exit";
echo " -v Be verbose";
@@ -61,12 +62,13 @@ usage ()
echo " -i Perform a system install into dst; implies -s";
echo " -I Perform a home install into dst; implies -s";
echo " -t Select the server process type (Master, Slave or Combined)";
echo " -S Write a pstats object to the given file when the server is stopped.";

if [ "${1-}" == "-" ]; then return 0; fi;
exit 64;
}

while getopts 'hvsfnpkrdP:i:I:t:K:' option; do
while getopts 'hvsfnpkrdP:i:I:t:K:S:' option; do
case "$option" in
'?') usage; ;;
'h') usage -; exit 0; ;;
@@ -83,6 +85,7 @@ while getopts 'hvsfnpkrdP:i:I:t:K:' option; do
'I') setup_only="true"; install="${wd}/build/dst"; install_flag="--root="; install_home="${OPTARG}"; ;;
't') service_type="${OPTARG}"; ;;
'K') read_key="${OPTARG}"; ;;
'S') profile="-p ${OPTARG}"; ;;
esac;
done;
shift $((${OPTIND} - 1));
@@ -231,7 +234,8 @@ run () {
-f "${config}" \
-T "${twisted}/bin/twistd" \
-P "${plugin_name}" \
-t "${service_type}";
-t "${service_type}" \
${profile};
cd /;
fi;
}

0 comments on commit 3df956a

Please sign in to comment.
You can’t perform that action at this time.