AIRAVATA-2352 Redirect stdout/stderr to log file
Project: http://git-wip-us.apache.org/repos/asf/airavata/repo Commit: http://git-wip-us.apache.org/repos/asf/airavata/commit/64fb9df0 Tree: http://git-wip-us.apache.org/repos/asf/airavata/tree/64fb9df0 Diff: http://git-wip-us.apache.org/repos/asf/airavata/diff/64fb9df0 Branch: refs/heads/develop Commit: 64fb9df0f81b730e6dbb70ee5a21740a02699261 Parents: 8be77fd Author: Marcus Christie <[email protected]> Authored: Fri Apr 21 11:46:24 2017 -0400 Committer: Marcus Christie <[email protected]> Committed: Fri Apr 21 11:46:24 2017 -0400 ---------------------------------------------------------------------- .../main/resources/bin/airavata-server-start.sh | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/airavata/blob/64fb9df0/modules/distribution/src/main/resources/bin/airavata-server-start.sh ---------------------------------------------------------------------- diff --git a/modules/distribution/src/main/resources/bin/airavata-server-start.sh b/modules/distribution/src/main/resources/bin/airavata-server-start.sh index f44661b..382e091 100644 --- a/modules/distribution/src/main/resources/bin/airavata-server-start.sh +++ b/modules/distribution/src/main/resources/bin/airavata-server-start.sh @@ -18,6 +18,8 @@ # under the License. . `dirname $0`/setenv.sh +# Capture user's working dir before changing directory +CWD="$PWD" cd ${AIRAVATA_HOME}/bin LOGO_FILE="logo.txt" @@ -29,6 +31,8 @@ IS_DAEMON_MODE=false LOGO=true IS_SUBSET=false SUBSET="" +DEFAULT_LOG_FILE="${AIRAVATA_HOME}/logs/output.log" +LOG_FILE=$DEFAULT_LOG_FILE # parse command arguments for var in "$@" @@ -64,6 +68,15 @@ do LOGO=false shift ;; + -log) + shift + LOG_FILE="$1" + shift + # If relative path, expand to absolute path using the user's $CWD + if [ -z "`echo "$LOG_FILE" | egrep "^/"`" ]; then + LOG_FILE="${CWD}/${LOG_FILE}" + fi + ;; -h) echo "Usage: airavata-server-start.sh [server-name/s] [command-options]" echo "Server names:" @@ -80,6 +93,7 @@ do echo " -nologo Do not show airavata logo" echo " -security Enable Java 2 security" echo " --<key>[=<value>] Server setting(s) to override or introduce (overrides values in airavata-server.properties)" + echo " -log <LOG_FILE> Where to redirect stdout/stderr (defaults to $DEFAULT_LOG_FILE)" echo " -h Display this help and exit" shift exit 0 @@ -114,8 +128,9 @@ fi if ${IS_DAEMON_MODE} ; then echo "Starting airavata server/s in daemon mode..." + echo "Redirecting output to $LOG_FILE" nohup java ${JAVA_OPTS} -classpath "${AIRAVATA_CLASSPATH}" \ - org.apache.airavata.server.ServerMain ${AIRAVATA_COMMAND} $* > /dev/null 2>&1 & + org.apache.airavata.server.ServerMain ${AIRAVATA_COMMAND} $* >> $LOG_FILE 2>&1 & else java ${JAVA_OPTS} -classpath "${AIRAVATA_CLASSPATH}" \ org.apache.airavata.server.ServerMain ${AIRAVATA_COMMAND} $*
