Commit 65e954e1 authored by Liang Ding's avatar Liang Ding

🎨 Fix #12683

parent 73829b83
...@@ -37,6 +37,8 @@ import org.b3log.latke.util.Strings; ...@@ -37,6 +37,8 @@ import org.b3log.latke.util.Strings;
import org.b3log.solo.event.*; import org.b3log.solo.event.*;
import org.b3log.solo.model.Option; import org.b3log.solo.model.Option;
import org.b3log.solo.model.Skin; import org.b3log.solo.model.Skin;
import org.b3log.solo.processor.InitCheckHandler;
import org.b3log.solo.processor.PermalinkHandler;
import org.b3log.solo.processor.console.*; import org.b3log.solo.processor.console.*;
import org.b3log.solo.repository.OptionRepository; import org.b3log.solo.repository.OptionRepository;
import org.b3log.solo.service.*; import org.b3log.solo.service.*;
...@@ -77,6 +79,9 @@ public final class SoloServletListener extends AbstractServletListener { ...@@ -77,6 +79,9 @@ public final class SoloServletListener extends AbstractServletListener {
public void contextInitialized(final ServletContextEvent servletContextEvent) { public void contextInitialized(final ServletContextEvent servletContextEvent) {
Latkes.setScanPath("org.b3log.solo"); Latkes.setScanPath("org.b3log.solo");
super.contextInitialized(servletContextEvent); super.contextInitialized(servletContextEvent);
DispatcherServlet.HANDLERS.add(0, new InitCheckHandler());
DispatcherServlet.HANDLERS.add(1, new PermalinkHandler());
beanManager = BeanManager.getInstance(); beanManager = BeanManager.getInstance();
routeConsoleProcessors(); routeConsoleProcessors();
Stopwatchs.start("Context Initialized"); Stopwatchs.start("Context Initialized");
...@@ -116,7 +121,7 @@ public final class SoloServletListener extends AbstractServletListener { ...@@ -116,7 +121,7 @@ public final class SoloServletListener extends AbstractServletListener {
pluginManager.load(); pluginManager.load();
if (initService.isInited()) { if (initService.isInited()) {
LOGGER.info("Solo is running [" + Latkes.getServePath() + "]"); LOGGER.info("Solo is running");
} }
Stopwatchs.end(); Stopwatchs.end();
......
...@@ -27,9 +27,7 @@ import org.eclipse.jetty.util.log.Log; ...@@ -27,9 +27,7 @@ import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.Slf4jLog; import org.eclipse.jetty.util.log.Slf4jLog;
import org.eclipse.jetty.webapp.WebAppContext; import org.eclipse.jetty.webapp.WebAppContext;
import java.awt.*;
import java.io.File; import java.io.File;
import java.net.URI;
/** /**
* Solo with embedded Jetty, <a href="https://github.com/b3log/solo/issues/12037">standalone mode</a>. * Solo with embedded Jetty, <a href="https://github.com/b3log/solo/issues/12037">standalone mode</a>.
...@@ -131,18 +129,32 @@ public final class Starter { ...@@ -131,18 +129,32 @@ public final class Starter {
portArg = "8080"; portArg = "8080";
} }
Latkes.init();
String serverScheme = commandLine.getOptionValue("server_scheme"); String serverScheme = commandLine.getOptionValue("server_scheme");
Latkes.setServerScheme(serverScheme); if (null != serverScheme) {
Latkes.setLatkeProperty("serveScheme", serverScheme);
}
String serverHost = commandLine.getOptionValue("server_host"); String serverHost = commandLine.getOptionValue("server_host");
Latkes.setServerHost(serverHost); if (null != serverHost) {
Latkes.setLatkeProperty("serverHost", serverHost);
}
String serverPort = commandLine.getOptionValue("server_port"); String serverPort = commandLine.getOptionValue("server_port");
Latkes.setServerPort(serverPort); if (null != serverPort) {
Latkes.setLatkeProperty("serverPort", serverPort);
}
String staticServerScheme = commandLine.getOptionValue("static_server_scheme"); String staticServerScheme = commandLine.getOptionValue("static_server_scheme");
Latkes.setStaticServerScheme(staticServerScheme); if (null != staticServerScheme) {
Latkes.setLatkeProperty("staticServerScheme", staticServerScheme);
}
String staticServerHost = commandLine.getOptionValue("static_server_host"); String staticServerHost = commandLine.getOptionValue("static_server_host");
Latkes.setStaticServerHost(staticServerHost); if (null != staticServerHost) {
Latkes.setLatkeProperty("staticServerHost", staticServerHost);
}
String staticServerPort = commandLine.getOptionValue("static_server_port"); String staticServerPort = commandLine.getOptionValue("static_server_port");
Latkes.setStaticServerPort(staticServerPort); if (null != staticServerPort) {
Latkes.setLatkeProperty("staticServerPort", staticServerPort);
}
String runtimeMode = commandLine.getOptionValue("runtime_mode"); String runtimeMode = commandLine.getOptionValue("runtime_mode");
if (null != runtimeMode) { if (null != runtimeMode) {
Latkes.setRuntimeMode(Latkes.RuntimeMode.valueOf(runtimeMode)); Latkes.setRuntimeMode(Latkes.RuntimeMode.valueOf(runtimeMode));
...@@ -170,18 +182,18 @@ public final class Starter { ...@@ -170,18 +182,18 @@ public final class Starter {
System.exit(-1); System.exit(-1);
} }
serverScheme = Latkes.getServerScheme(); // serverScheme = Latkes.getServerScheme();
serverHost = Latkes.getServerHost(); // serverHost = Latkes.getServerHost();
serverPort = Latkes.getServerPort(); // serverPort = Latkes.getServerPort();
final String contextPath = Latkes.getContextPath(); // final String contextPath = Latkes.getContextPath();
//
try { // try {
if (!commandLine.hasOption("no")) { // if (!commandLine.hasOption("no")) {
Desktop.getDesktop().browse(new URI(serverScheme + "://" + serverHost + ":" + serverPort + contextPath)); // Desktop.getDesktop().browse(new URI(serverScheme + "://" + serverHost + ":" + serverPort + contextPath));
} // }
} catch (final Throwable e) { // } catch (final Throwable e) {
// Ignored // // Ignored
} // }
Runtime.getRuntime().addShutdownHook(new Thread(() -> { Runtime.getRuntime().addShutdownHook(new Thread(() -> {
try { try {
......
...@@ -162,7 +162,7 @@ public class InitService { ...@@ -162,7 +162,7 @@ public class InitService {
try { try {
inited = !optionRepository.getList(new Query()).isEmpty(); inited = !optionRepository.getList(new Query()).isEmpty();
if (!inited && !printedInitMsg) { if (!inited && !printedInitMsg) {
LOGGER.log(Level.WARN, "Solo has not been initialized, please open your browser and visit [" + Latkes.getServePath() + "] to init Solo"); LOGGER.log(Level.WARN, "Solo has not been initialized, please open your browser to init Solo");
printedInitMsg = true; printedInitMsg = true;
} }
......
...@@ -17,18 +17,14 @@ ...@@ -17,18 +17,14 @@
# #
# #
# Description: B3log Latke configurations. Configures the section "Server" carefully. # Description: B3log Latke configurations.
# Version: 1.5.3.10, Sep 22, 2018 # Version: 1.6.0.0, Mar 1, 2019
# Author: Liang Ding # Author: Liang Ding
# #
#### Server #### #### Server ####
# Browser visit protocol # Browser visit protocol
serverScheme=http serverScheme=http
# Browser visit domain name
serverHost=localhost
# Browser visit port, 80 as usual, THIS IS NOT SERVER LISTEN PORT!
serverPort=8080
#### Cookie #### #### Cookie ####
cookieName=solo cookieName=solo
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment