This is an automated email from the ASF dual-hosted git repository.
zhongjiajie pushed a commit to branch 2.0.2-prepare
in repository https://gitbox.apache.org/repos/asf/dolphinscheduler.git
The following commit(s) were added to refs/heads/2.0.2-prepare by this push:
new 250e857 Fix python gateway will start each time others server start
(#7648)
250e857 is described below
commit 250e857c7094f6321312e1c4cadf5f1d9ff1f838
Author: Jiajie Zhong <[email protected]>
AuthorDate: Mon Dec 27 18:10:28 2021 +0800
Fix python gateway will start each time others server start (#7648)
Add PythonGatewayServer to StandaloneServer
Change ComponentScan
Add log file and server start log
---
.../server/PythonGatewayServer.java | 17 ++++---
.../src/main/resources/logback-python-gateway.xml | 52 ++++++++++++++++++++++
.../dolphinscheduler/server/StandaloneServer.java | 3 +-
3 files changed, 66 insertions(+), 6 deletions(-)
diff --git
a/dolphinscheduler-python/src/main/java/org/apache/dolphinscheduler/server/PythonGatewayServer.java
b/dolphinscheduler-python/src/main/java/org/apache/dolphinscheduler/server/PythonGatewayServer.java
index 79087cf..aeb1931 100644
---
a/dolphinscheduler-python/src/main/java/org/apache/dolphinscheduler/server/PythonGatewayServer.java
+++
b/dolphinscheduler-python/src/main/java/org/apache/dolphinscheduler/server/PythonGatewayServer.java
@@ -60,15 +60,21 @@ import javax.annotation.PostConstruct;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.boot.SpringApplication;
-import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.boot.builder.SpringApplicationBuilder;
import
org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
import org.springframework.context.annotation.ComponentScan;
+import org.springframework.context.annotation.FilterType;
import py4j.GatewayServer;
-@SpringBootApplication
-@ComponentScan(value = "org.apache.dolphinscheduler")
+@ComponentScan(value = "org.apache.dolphinscheduler", excludeFilters = {
+ @ComponentScan.Filter(type = FilterType.REGEX, pattern = {
+ "org.apache.dolphinscheduler.server.worker.*",
+ "org.apache.dolphinscheduler.server.monitor.*",
+ "org.apache.dolphinscheduler.server.log.*",
+ "org.apache.dolphinscheduler.alert.*"
+ })
+})
public class PythonGatewayServer extends SpringBootServletInitializer {
private static final Logger LOGGER =
LoggerFactory.getLogger(PythonGatewayServer.class);
@@ -468,10 +474,11 @@ public class PythonGatewayServer extends
SpringBootServletInitializer {
GatewayServer server = new GatewayServer(this);
GatewayServer.turnLoggingOn();
// Start server to accept python client socket
+ LOGGER.info("Start python gateway server.");
server.start();
}
public static void main(String[] args) {
- SpringApplication.run(PythonGatewayServer.class, args);
+ new SpringApplicationBuilder(PythonGatewayServer.class).run(args);
}
}
diff --git
a/dolphinscheduler-python/src/main/resources/logback-python-gateway.xml
b/dolphinscheduler-python/src/main/resources/logback-python-gateway.xml
new file mode 100644
index 0000000..42e612c
--- /dev/null
+++ b/dolphinscheduler-python/src/main/resources/logback-python-gateway.xml
@@ -0,0 +1,52 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ 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.
+ -->
+
+<!-- Logback configuration. See http://logback.qos.ch/manual/index.html -->
+<configuration scan="true" scanPeriod="120 seconds">
+
+ <property name="log.base" value="logs"/>
+ <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
+ <encoder>
+ <pattern>
+ [%level] %date{yyyy-MM-dd HH:mm:ss.SSS} %logger{96}:[%line] -
%msg%n
+ </pattern>
+ <charset>UTF-8</charset>
+ </encoder>
+ </appender>
+
+ <appender name="PYTHONGATEWAYLOGFILE"
class="ch.qos.logback.core.rolling.RollingFileAppender">
+ <file>${log.base}/dolphinscheduler-python-gateway.log</file>
+ <rollingPolicy
class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
+
<fileNamePattern>${log.base}/dolphinscheduler-python-gateway.%d{yyyy-MM-dd_HH}.%i.log</fileNamePattern>
+ <maxHistory>20</maxHistory>
+ <maxFileSize>64MB</maxFileSize>
+ </rollingPolicy>
+ <encoder>
+ <pattern>
+ [%level] %date{yyyy-MM-dd HH:mm:ss.SSS} %logger{96}:[%line] -
%msg%n
+ </pattern>
+ <charset>UTF-8</charset>
+ </encoder>
+ </appender>
+
+ <root level="INFO">
+ <appender-ref ref="STDOUT"/>
+ <appender-ref ref="PYTHONGATEWAYLOGFILE"/>
+ </root>
+
+</configuration>
diff --git
a/dolphinscheduler-standalone-server/src/main/java/org/apache/dolphinscheduler/server/StandaloneServer.java
b/dolphinscheduler-standalone-server/src/main/java/org/apache/dolphinscheduler/server/StandaloneServer.java
index 05204b2..c216c07 100644
---
a/dolphinscheduler-standalone-server/src/main/java/org/apache/dolphinscheduler/server/StandaloneServer.java
+++
b/dolphinscheduler-standalone-server/src/main/java/org/apache/dolphinscheduler/server/StandaloneServer.java
@@ -39,7 +39,8 @@ public class StandaloneServer {
ApiApplicationServer.class,
MasterServer.class,
WorkerServer.class,
- AlertServer.class
+ AlertServer.class,
+ PythonGatewayServer.class
).profiles("master", "worker", "api", "alert", "python-gateway", "h2",
"standalone").run(args);
}
}