Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ public static void logCode(Logger log) {
FmtLog.info(log, "%s %s", serverName, version);
}

/** Details of the system runtime configuration. */
public static void logSystemDetails(Logger log) {
PlatformInfo.logSystemDetails(log);
}

/** Log details - this function is about command line details */
public static void logServerCmdSetup(Logger log, boolean verbose, DataAccessPointRegistry dapRegistry,
String datasetPath, String datasetDescription, String serverConfigFile, String staticFiles) {
Expand All @@ -47,7 +52,7 @@ public static void logServerCmdSetup(Logger log, boolean verbose, DataAccessPoin
FusekiCoreInfo.logDataAccessPointRegistry(log, dapRegistry, verbose);
if ( staticFiles != null )
FmtLog.info(log, "Static files: %s", staticFiles);
PlatformInfo.logDetailsSystem(log);
PlatformInfo.logSystemDetails(log);
if ( verbose )
PlatformInfo.logDetailsJVM(log);
}
Expand Down Expand Up @@ -129,5 +134,4 @@ private static List<Operation> operations(DataService dataService) {
others.stream().sorted(order).forEach(nice::add);
return nice;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import org.apache.jena.atlas.logging.FmtLog;
import org.slf4j.Logger;

/** Platform inforamtion - OS and JVM */
/** Platform information - OS and JVM */
/*package*/ class PlatformInfo {

public static void main(String ...args) throws IOException {
Expand All @@ -37,7 +37,7 @@ public static void main(String ...args) throws IOException {
}

/** System details */
/*package*/ static void logDetailsSystem(Logger log) {
/*package*/ static void logSystemDetails(Logger log) {
String prefix = " ";
long maxMem = Runtime.getRuntime().maxMemory();
long totalMem = Runtime.getRuntime().totalMemory();
Expand All @@ -56,7 +56,7 @@ public static void main(String ...args) throws IOException {

/** JVM details section. */
/*package*/ static void logDetailsJVM(Logger log) {
String prefix = " ";
String prefix = " ";
logOne(log, prefix, "java.vendor");
logOne(log, prefix, "java.home");
logOne(log, prefix, "java.runtime.version");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
import org.apache.jena.fuseki.main.cmds.FusekiMain;
import org.apache.jena.fuseki.main.sys.FusekiModules;
import org.apache.jena.fuseki.server.FusekiServerRunner;
import org.apache.jena.sys.JenaSystem;
import org.slf4j.Logger;

/**
* Functions for building and runner a {@link FusekiServer} configured from command line arguments.
Expand All @@ -33,13 +35,20 @@
*/
public class FusekiMainRunner {

static { JenaSystem.init(); }

/**
* Run a plain {@link FusekiServer}.
* @param args line arguments.
* @return Return the running server.
*/
public static FusekiServer runAsync(String... args) {
FusekiServer server = construct(args);
startAsync(server);
return server;
}

private static FusekiServer startAsync(FusekiServer server) {
try {
return server.start();
} catch (FusekiException ex) {
Expand All @@ -58,7 +67,12 @@ public static FusekiServer runAsync(String... args) {
* This function does not return.
*/
public static void run(String... args) {
FusekiServer server = runAsync(args);
Logger log = Fuseki.fusekiLog;
FusekiRunner.logCode(log);
FusekiServer server = construct(args);
FusekiRunner.logServerSetup(log, server);
startAsync(server);
FusekiRunner.logServerStart(log, server);
server.join();
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/*
* 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.
*
* SPDX-License-Identifier: Apache-2.0
*/

package org.apache.jena.fuseki.main;

import org.apache.jena.fuseki.Fuseki;
import org.apache.jena.fuseki.FusekiException;
import org.apache.jena.fuseki.server.FusekiCoreInfo;
import org.slf4j.Logger;

public class FusekiRunner {

// ---- Logging fragments

public static void logCode(Logger log) {
FusekiCoreInfo.logCode(log);
}

public static void logServerSetup(Logger log, FusekiServer server) {
boolean verbose = Fuseki.getVerbose(server.getServletContext());
FusekiCoreInfo.logDataAccessPointRegistry(log, server.getDataAccessPointRegistry(), verbose);
FusekiCoreInfo.logSystemDetails(log);
}

public static void logServerStart(Logger log, FusekiServer server) {
if ( ! server.getJettyServer().isStarted() )
throw new FusekiException("FusekiServer not ready");
int httpPort = server.getHttpPort();
int httpsPort = server.getHttpsPort();
if ( httpsPort > 0 && httpPort > 0 )
Fuseki.serverLog.info("Start Fuseki (http="+httpPort+" https="+httpsPort+")");
else if ( httpsPort > 0 )
Fuseki.serverLog.info("Start Fuseki (https="+httpsPort+")");
else if ( httpPort > 0 )
Fuseki.serverLog.info("Start Fuseki (http="+httpPort+")");
else
Fuseki.serverLog.info("Start Fuseki");
}

public static void logServerStop(Logger log, FusekiServer server) {
log.info("Stopping Fuseki");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,9 @@ public String getConfigFilename() {
* To synchronise with the server stopping, call {@link #join}.
*/
public FusekiServer start() {
if ( server.isRunning() )
return this;

try {
FusekiModuleStep.serverBeforeStarting(this);
server.start();
Expand Down Expand Up @@ -373,18 +376,7 @@ public FusekiServer start() {

FusekiModuleStep.serverAfterStarting(this);

if ( httpsPort > 0 && httpPort > 0 )
Fuseki.serverLog.info("Start Fuseki (http="+httpPort+" https="+httpsPort+")");
else if ( httpsPort > 0 )
Fuseki.serverLog.info("Start Fuseki (https="+httpsPort+")");
else if ( httpPort > 0 )
Fuseki.serverLog.info("Start Fuseki (http="+httpPort+")");
else
Fuseki.serverLog.info("Start Fuseki");

// Any post-startup configuration here.
// --
// Done!
return this;
}

Expand Down Expand Up @@ -418,7 +410,7 @@ public void stop() {
public void join() {
try {
if ( ! server.isStarted() && ! server.isStarting() )
server.start();
start();
server.join(); }
catch (FusekiException e) { throw e; }
catch (Exception e) { throw new FusekiException(e); }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

package org.apache.jena.fuseki.main.cmds;

import org.apache.jena.fuseki.main.FusekiMainRunner;
import org.apache.jena.fuseki.system.FusekiLogging;

/** Fuseki command that runs a Fuseki server without the admin UI, just SPARQL services.
Expand All @@ -43,7 +44,7 @@ public class FusekiMainCmd {
* return. See {@link FusekiMain#build} to build a server using command line
* syntax but not start it.
*/
static public void main(String... argv) {
FusekiMain.run(argv);
static public void main(String... args) {
FusekiMainRunner.run(args);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public class FusekiServerCmd {
* syntax but not start it.
*/
static public void main(String... args) {
FusekiServerRunner.construct(args).join();
FusekiServerRunner.run(args);
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,16 @@
import org.apache.jena.fuseki.Fuseki;
import org.apache.jena.fuseki.FusekiException;
import org.apache.jena.fuseki.main.FusekiMainRunner;
import org.apache.jena.fuseki.main.FusekiRunner;
import org.apache.jena.fuseki.main.FusekiServer;
import org.apache.jena.fuseki.main.cmds.FusekiMain;
import org.apache.jena.fuseki.main.cmds.ServerArgs;
import org.apache.jena.fuseki.main.sys.FusekiModules;
import org.apache.jena.fuseki.main.sys.FusekiServerArgsCustomiser;
import org.apache.jena.fuseki.mgt.FusekiServerCtl;
import org.apache.jena.fuseki.mod.FusekiServerModules;
import org.apache.jena.sys.JenaSystem;
import org.slf4j.Logger;

/**
* Functions for building and runner a {@link FusekiServer} configured from command line arguments
Expand All @@ -42,13 +45,20 @@
*/
public class FusekiServerRunner {

static { JenaSystem.init(); }

/**
* Run {@link FusekiServer} with {@link FusekiModules} as given by {@link FusekiServerModules#serverModules()}.
* @param args Command line arguments.
* @return Return the running server.
*/
public static FusekiServer runAsync(String... args) {
FusekiServer server = construct(args);
startAsync(server);
return server;
}

private static FusekiServer startAsync(FusekiServer server) {
try {
return server.start();
} catch (FusekiException ex) {
Expand All @@ -67,7 +77,12 @@ public static FusekiServer runAsync(String... args) {
* This function does not return.
*/
public static void run(String... args) {
FusekiServer server = runAsync(args);
Logger log = Fuseki.fusekiLog;
FusekiRunner.logCode(log);
FusekiServer server = construct(args);
FusekiRunner.logServerSetup(log, server);
startAsync(server);
FusekiRunner.logServerStart(log, server);
server.join();
}

Expand Down
Loading