forked from apache/flink
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FLINK-4326] [scripts] Flink foreground services
Add a "start-foreground" option to the Flink service scripts which does not daemonize the service nor redirect output. This closes apache#3492. This closes apache#3351.
- Loading branch information
Showing
7 changed files
with
200 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
#!/usr/bin/env bash | ||
################################################################################ | ||
# Licensed to the Apache Software Foundation (ASF) under one | ||
# or more contributor license agreements. See the NOTICE file | ||
# distributed with this work for additional information | ||
# regarding copyright ownership. The ASF licenses this file | ||
# to you under the Apache License, Version 2.0 (the | ||
# "License"); you may not use this file except in compliance | ||
# with the License. You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
################################################################################ | ||
|
||
# Start a Flink service as a console application. Must be stopped with Ctrl-C | ||
# or with SIGTERM by kill or the controlling process. | ||
USAGE="Usage: flink-console.sh (jobmanager|taskmanager|zookeeper) [args]" | ||
|
||
SERVICE=$1 | ||
ARGS=("${@:2}") # get remaining arguments as array | ||
|
||
bin=`dirname "$0"` | ||
bin=`cd "$bin"; pwd` | ||
|
||
. "$bin"/config.sh | ||
|
||
case $SERVICE in | ||
(jobmanager) | ||
CLASS_TO_RUN=org.apache.flink.runtime.jobmanager.JobManager | ||
;; | ||
|
||
(taskmanager) | ||
CLASS_TO_RUN=org.apache.flink.runtime.taskmanager.TaskManager | ||
;; | ||
|
||
(zookeeper) | ||
CLASS_TO_RUN=org.apache.flink.runtime.zookeeper.FlinkZooKeeperQuorumPeer | ||
;; | ||
|
||
(*) | ||
echo "Unknown service '${SERVICE}'. $USAGE." | ||
exit 1 | ||
;; | ||
esac | ||
|
||
FLINK_TM_CLASSPATH=`constructFlinkClassPath` | ||
|
||
log_setting=("-Dlog4j.configuration=file:${FLINK_CONF_DIR}/log4j-console.properties" "-Dlogback.configurationFile=file:${FLINK_CONF_DIR}/logback-console.xml") | ||
|
||
JAVA_VERSION=$(${JAVA_RUN} -version 2>&1 | sed 's/.*version "\(.*\)\.\(.*\)\..*"/\1\2/; 1q') | ||
|
||
# Only set JVM 8 arguments if we have correctly extracted the version | ||
if [[ ${JAVA_VERSION} =~ ${IS_NUMBER} ]]; then | ||
if [ "$JAVA_VERSION" -lt 18 ]; then | ||
JVM_ARGS="$JVM_ARGS -XX:MaxPermSize=256m" | ||
fi | ||
fi | ||
|
||
echo "Starting $SERVICE as a console application on host $HOSTNAME." | ||
$JAVA_RUN $JVM_ARGS ${FLINK_ENV_JAVA_OPTS} "${log_setting[@]}" -classpath "`manglePathList "$FLINK_TM_CLASSPATH:$INTERNAL_HADOOP_CLASSPATHS"`" ${CLASS_TO_RUN} "${ARGS[@]}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
flink-dist/src/main/flink-bin/conf/log4j-console.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
################################################################################ | ||
# Licensed to the Apache Software Foundation (ASF) under one | ||
# or more contributor license agreements. See the NOTICE file | ||
# distributed with this work for additional information | ||
# regarding copyright ownership. The ASF licenses this file | ||
# to you under the Apache License, Version 2.0 (the | ||
# "License"); you may not use this file except in compliance | ||
# with the License. You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
################################################################################ | ||
|
||
# This affects logging for both user code and Flink | ||
log4j.rootLogger=INFO, console | ||
|
||
# Uncomment this if you want to _only_ change Flink's logging | ||
#log4j.logger.org.apache.flink=INFO | ||
|
||
# The following lines keep the log level of common libraries/connectors on | ||
# log level INFO. The root logger does not override this. You have to manually | ||
# change the log levels here. | ||
log4j.logger.akka=INFO | ||
log4j.logger.org.apache.kafka=INFO | ||
log4j.logger.org.apache.hadoop=INFO | ||
log4j.logger.org.apache.zookeeper=INFO | ||
|
||
# Log all infos to the console | ||
log4j.appender.console=org.apache.log4j.ConsoleAppender | ||
log4j.appender.console.layout=org.apache.log4j.PatternLayout | ||
log4j.appender.console.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss,SSS} %-5p %-60c %x - %m%n | ||
|
||
# Suppress the irrelevant (wrong) warnings from the Netty channel handler | ||
log4j.logger.org.jboss.netty.channel.DefaultChannelPipeline=ERROR, console |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
<!-- | ||
~ Licensed to the Apache Software Foundation (ASF) under one | ||
~ or more contributor license agreements. See the NOTICE file | ||
~ distributed with this work for additional information | ||
~ regarding copyright ownership. The ASF licenses this file | ||
~ to you under the Apache License, Version 2.0 (the | ||
~ "License"); you may not use this file except in compliance | ||
~ with the License. You may obtain a copy of the License at | ||
~ | ||
~ http://www.apache.org/licenses/LICENSE-2.0 | ||
~ | ||
~ Unless required by applicable law or agreed to in writing, software | ||
~ distributed under the License is distributed on an "AS IS" BASIS, | ||
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
~ See the License for the specific language governing permissions and | ||
~ limitations under the License. | ||
--> | ||
|
||
<configuration> | ||
<appender name="console" class="ch.qos.logback.core.ConsoleAppender"> | ||
<encoder> | ||
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{60} %X{sourceThread} - %msg%n</pattern> | ||
</encoder> | ||
</appender> | ||
|
||
<!-- This affects logging for both user code and Flink --> | ||
<root level="INFO"> | ||
<appender-ref ref="console"/> | ||
</root> | ||
|
||
<!-- Uncomment this if you want to only change Flink's logging --> | ||
<!--<logger name="org.apache.flink" level="INFO">--> | ||
<!--<appender-ref ref="console"/>--> | ||
<!--</logger>--> | ||
|
||
<!-- The following lines keep the log level of common libraries/connectors on | ||
log level INFO. The root logger does not override this. You have to manually | ||
change the log levels here. --> | ||
<logger name="akka" level="INFO"> | ||
<appender-ref ref="console"/> | ||
</logger> | ||
<logger name="org.apache.kafka" level="INFO"> | ||
<appender-ref ref="console"/> | ||
</logger> | ||
<logger name="org.apache.hadoop" level="INFO"> | ||
<appender-ref ref="console"/> | ||
</logger> | ||
<logger name="org.apache.zookeeper" level="INFO"> | ||
<appender-ref ref="console"/> | ||
</logger> | ||
|
||
<!-- Suppress the irrelevant (wrong) warnings from the Netty channel handler --> | ||
<logger name="org.jboss.netty.channel.DefaultChannelPipeline" level="ERROR"> | ||
<appender-ref ref="console"/> | ||
</logger> | ||
</configuration> |