[
https://issues.apache.org/jira/browse/KNOX-2157?focusedWorklogId=367396&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-367396
]
ASF GitHub Bot logged work on KNOX-2157:
----------------------------------------
Author: ASF GitHub Bot
Created on: 07/Jan/20 10:12
Start Date: 07/Jan/20 10:12
Worklog Time Spent: 10m
Work Description: smolnar82 commented on pull request #230: KNOX-2157 -
Verifying the server's state in addition to PID check at gateway start and
registering shutdown hook in order to stop the server gracefully.
URL: https://github.com/apache/knox/pull/230#discussion_r363677522
##########
File path:
gateway-server/src/main/java/org/apache/knox/gateway/GatewayServerLifecyleListener.java
##########
@@ -0,0 +1,86 @@
+/*
+ * 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.knox.gateway;
+
+import java.io.IOException;
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.Locale;
+
+import org.apache.knox.gateway.config.GatewayConfig;
+import org.apache.knox.gateway.i18n.messages.MessagesFactory;
+import org.eclipse.jetty.util.component.LifeCycle;
+
+public class GatewayServerLifecyleListener implements LifeCycle.Listener {
+
+ private static final GatewayMessages log =
MessagesFactory.get(GatewayMessages.class);
+
+ private static final ThreadLocal<DateFormat> DATE_FORMAT =
ThreadLocal.withInitial(() -> new
SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ", Locale.getDefault()));
+
+ private enum Status {
+ STARTING, STARTED, FAILURE, STOPPING, STOPPED
+ };
+
+ private final Path lifeCylceFilePath;
Review comment:
Done.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
Issue Time Tracking
-------------------
Worklog Id: (was: 367396)
Time Spent: 1.5h (was: 1h 20m)
> Knox should check if it's actually up&running
> ---------------------------------------------
>
> Key: KNOX-2157
> URL: https://issues.apache.org/jira/browse/KNOX-2157
> Project: Apache Knox
> Issue Type: New Feature
> Components: Server
> Affects Versions: 1.1.0, 1.2.0, 1.3.0
> Reporter: Sandor Molnar
> Assignee: Sandor Molnar
> Priority: Major
> Fix For: 1.4.0
>
> Time Spent: 1.5h
> Remaining Estimate: 0h
>
> As of now, Knox returns a success code in case the process is being created.
> There should be another way to check if the server is actually up&running and
> is capable of serving incoming requests.
> My proposal is:
> * the Knox startup script should be modified to run a basic Admin API check
> in case {{--test-gateway-url}} is defined in the startup command. If this is
> blank or non-defined we fallback to the existing PID-based check
> * two more optional arguments will be defined for this feature:
> ** {{--test-gateway-retry-attempts}}: indicates the number of tries the
> startup script should execute before it fails. Defaults to 5.
> ** {{--test-gateway-retry-sleep}}: the amount of time that the test process
> will wait or sleep before a retry is issued. Defaults to 2s.
> The new-style check will use {{curl}} and will return success in case
> {{$GATEWAY_TEST_URL/gateway/admin/api/v1/version/}} returns an HTTP response
> with code 200. If this is not true; the startup script should return an error
> code.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)