This is an automated email from the ASF dual-hosted git repository.

suvasude pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-gobblin.git


The following commit(s) were added to refs/heads/master by this push:
     new d9e4f9a  [GOBBLIN-925] Create option to log outputs to console, fix 
docker-compose
d9e4f9a is described below

commit d9e4f9a39f56c845d82fceb1a0c410655bca09b0
Author: William Lo <[email protected]>
AuthorDate: Mon Oct 28 13:58:32 2019 -0700

    [GOBBLIN-925] Create option to log outputs to console, fix docker-compose
    
    Closes #2782 from Will-Lo/log-from-local
---
 bin/gobblin.sh                                            | 15 +++++++++++++--
 conf/standalone/log4j.xml                                 |  8 ++++++++
 .../gobblin-service/alpine-gaas-latest/entrypoint.sh      |  3 +--
 .../alpine-gobblin-latest/entrypoint.sh                   |  3 +--
 4 files changed, 23 insertions(+), 6 deletions(-)

diff --git a/bin/gobblin.sh b/bin/gobblin.sh
index 7e32a90..d82f75b 100755
--- a/bin/gobblin.sh
+++ b/bin/gobblin.sh
@@ -46,6 +46,7 @@ EXTRA_JARS=''
 VERBOSE=0
 ENABLE_GC_LOGS=0
 CMD_PARAMS=''
+LOG_TO_STDOUT=0
 
 # Gobblin Commands, Modes & respective Classes
 GOBBLIN_MODE_TYPE=''
@@ -133,6 +134,7 @@ function print_gobblin_service_usage() {
     echo "    --jt <resource manager URL>           Only for mapreduce mode: 
Job submission URL, if not set, taken from \${HADOOP_HOME}/conf."
     echo "    --fs <file system URL>                Only for mapreduce mode: 
Target file system, if not set, taken from \${HADOOP_HOME}/conf."
     echo "    --job-conf-file <job-conf-file-path>  Only for mapreduce mode: 
configuration file for the job to run"
+    echo "    --log-to-stdout                     Outputs to stdout rather 
than to a log file"
     echo "    --help                                Display this help."
     echo "    --verbose                             Display full command used 
to start the process."
     echo "                                          Gobblin Version: 
$GOBBLIN_VERSION"
@@ -221,6 +223,9 @@ do
             JOB_CONF_FILE="$2"
             shift
         ;;
+        --log-to-stdout)
+            LOG_TO_STDOUT=1
+        ;;
         *)
             CMD_PARAMS="$CMD_PARAMS $1"
         ;;
@@ -464,10 +469,16 @@ function start() {
         fi
 
         # execute the command
-        if [[ $VERBOSE -eq 1 ]]; then
+        if [ $VERBOSE -eq 1 ] && [ $LOG_TO_STDOUT -eq 1 ]; then
+            echo "Running command: $GOBBLIN_COMMAND"
+        elif [[ $VERBOSE -eq 1 ]]; then
             echo "Running command: $GOBBLIN_COMMAND 1>> ${LOG_OUT_FILE} 2>> 
${LOG_ERR_FILE}";
         fi
-        nohup $GOBBLIN_COMMAND 1>> ${LOG_OUT_FILE} 2>> ${LOG_ERR_FILE} &
+        if [[ LOG_TO_STDOUT -eq 1 ]]; then
+          $GOBBLIN_COMMAND
+        else
+          nohup $GOBBLIN_COMMAND 1>> ${LOG_OUT_FILE} 2>> ${LOG_ERR_FILE} &
+        fi
         PID=$!
         echo $PID >> $PID_FILE
         if [[ $? != 0 ]]; then
diff --git a/conf/standalone/log4j.xml b/conf/standalone/log4j.xml
index 436a2b0..fad768c 100644
--- a/conf/standalone/log4j.xml
+++ b/conf/standalone/log4j.xml
@@ -16,6 +16,13 @@
     </layout>
   </appender>
 
+
+  <appender name="console" class="org.apache.log4j.ConsoleAppender">
+    <layout class="org.apache.log4j.PatternLayout">
+      <param name="ConversionPattern" value="%d{yyyy-MM-dd HH:mm:ss z} %-5p 
[%t] %C %X{tableName} %L - %m%n"/>
+    </layout>
+  </appender>
+
   <logger name="org.apache.commons.httpclient">
     <level value="DEBUG"/>
   </logger>
@@ -27,6 +34,7 @@
   <root>
     <priority value ="INFO" />
     <appender-ref ref="FileRoll" />
+    <appender-ref ref="console" />
   </root>
 
 </log4j:configuration>
\ No newline at end of file
diff --git a/gobblin-docker/gobblin-service/alpine-gaas-latest/entrypoint.sh 
b/gobblin-docker/gobblin-service/alpine-gaas-latest/entrypoint.sh
index 68b870e..86960cc 100755
--- a/gobblin-docker/gobblin-service/alpine-gaas-latest/entrypoint.sh
+++ b/gobblin-docker/gobblin-service/alpine-gaas-latest/entrypoint.sh
@@ -17,6 +17,5 @@
 #
 GOBBLIN_HOME="$(cd `dirname $0`/..; pwd)"
 
-./bin/gobblin.sh service gobblin-as-service start 
alpine-gaas-latest_gobblin-standalone
-busybox tail -F $GOBBLIN_HOME/logs/gobblin-as-service.out
+./bin/gobblin.sh service gobblin-as-service start --log-to-stdout $@
 
diff --git 
a/gobblin-docker/gobblin-standalone/alpine-gobblin-latest/entrypoint.sh 
b/gobblin-docker/gobblin-standalone/alpine-gobblin-latest/entrypoint.sh
index a122e9d..b5875da 100644
--- a/gobblin-docker/gobblin-standalone/alpine-gobblin-latest/entrypoint.sh
+++ b/gobblin-docker/gobblin-standalone/alpine-gobblin-latest/entrypoint.sh
@@ -17,5 +17,4 @@
 #
 GOBBLIN_HOME="$(cd `dirname $0`/..; pwd)"
 
-./bin/gobblin.sh service standalone start
-busybox tail -F ${GOBBLIN_HOME}/logs/standalone.out
\ No newline at end of file
+./bin/gobblin.sh service standalone start --log-to-stdout $@

Reply via email to