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

peacewong pushed a commit to branch dev-1.2.0
in repository https://gitbox.apache.org/repos/asf/incubator-linkis.git


The following commit(s) were added to refs/heads/dev-1.2.0 by this push:
     new 533358149 [Feat][Common] Add common rest api /offline for all services 
(#2268)
533358149 is described below

commit 53335814968343c7e03a1da8f18782300829edc6
Author: legendtkl <[email protected]>
AuthorDate: Sun Jun 12 21:29:48 2022 +0800

    [Feat][Common] Add common rest api /offline for all services (#2268)
---
 .../assembly-combined/conf/linkis.properties       |  1 +
 assembly-combined-package/bin/install.sh           |  1 -
 .../apache/linkis/restful/CommonRestfulApi.java    | 42 ++++++++++++++++++++++
 3 files changed, 43 insertions(+), 1 deletion(-)

diff --git a/assembly-combined-package/assembly-combined/conf/linkis.properties 
b/assembly-combined-package/assembly-combined/conf/linkis.properties
index 4adf5de85..780dd6fdb 100644
--- a/assembly-combined-package/assembly-combined/conf/linkis.properties
+++ b/assembly-combined-package/assembly-combined/conf/linkis.properties
@@ -51,6 +51,7 @@ wds.linkis.home=/appcom/Install/LinkisInstall
 #Linkis governance station administrators
 wds.linkis.governance.station.admin=hadoop
 
wds.linkis.gateway.conf.publicservice.list=query,jobhistory,application,configuration,filesystem,udf,variable,microservice,errorcode,bml,datasource
+wds.linkis.server.user.restful.uri.pass.auth=/actuator/prometheus,/api/rest_j/v1/offline
 
 spring.spring.servlet.multipart.max-file-size=500MB
 spring.spring.servlet.multipart.max-request-size=500MB
diff --git a/assembly-combined-package/bin/install.sh 
b/assembly-combined-package/bin/install.sh
index bcc33d0b3..04a1f5cc5 100644
--- a/assembly-combined-package/bin/install.sh
+++ b/assembly-combined-package/bin/install.sh
@@ -405,7 +405,6 @@ if [ "true" == "$PROMETHEUS_ENABLE" ]
 then
   echo "prometheus is enabled"
   sed -i ${txt} '$a \wds.linkis.prometheus.enable={{ PROMETHEUS_ENABLE }}' 
$LINKIS_HOME/conf/linkis.properties
-  sed -i ${txt} '$a 
\wds.linkis.server.user.restful.uri.pass.auth=/actuator/prometheus,' 
$LINKIS_HOME/conf/linkis.properties
   sed -i ${txt}  '/eureka:/a \\  instance:\n    metadata-map:\n      
prometheus.path: ${prometheus.path:${prometheus.endpoint}}' 
$LINKIS_HOME/conf/application-linkis.yml
   sed -i ${txt}  's#include: refresh,info#include: 
refresh,info,health,metrics,prometheus#g' 
$LINKIS_HOME/conf/application-linkis.yml
   sed -i ${txt} '/instance:/a \    metadata-map:\n      prometheus.path: 
${prometheus.path:/actuator/prometheus}' 
$LINKIS_HOME/conf/application-eureka.yml
diff --git 
a/linkis-commons/linkis-module/src/main/java/org/apache/linkis/restful/CommonRestfulApi.java
 
b/linkis-commons/linkis-module/src/main/java/org/apache/linkis/restful/CommonRestfulApi.java
new file mode 100644
index 000000000..ac0c14a80
--- /dev/null
+++ 
b/linkis-commons/linkis-module/src/main/java/org/apache/linkis/restful/CommonRestfulApi.java
@@ -0,0 +1,42 @@
+/*
+ * 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.
+ */
+
+package org.apache.linkis.restful;
+
+import org.apache.linkis.server.Message;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.cloud.client.discovery.DiscoveryClient;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RestController;
+
+import javax.servlet.http.HttpServletRequest;
+
+import com.netflix.discovery.DiscoveryManager;
+
+@RestController
+@RequestMapping(path = "/")
+public class CommonRestfulApi {
+    @Autowired private DiscoveryClient client;
+
+    @RequestMapping(path = "/offline", method = RequestMethod.GET)
+    public Message offline(HttpServletRequest req) {
+        DiscoveryManager.getInstance().shutdownComponent();
+        return Message.ok().data("msg", "Offline successfully.");
+    }
+}


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to