Commit 6c340a44 authored by Liang Ding's avatar Liang Ding

Fix #12044

parent 728d4f68
<?xml version="1.0" encoding="UTF-8"?>
<!--
Description: Solo POM.
Version: 2.7.1.8, Nov 18, 2015
Version: 2.8.1.8, Nov 29, 2015
Author: Liang Ding
-->
<project xmlns="http://maven.apache.org/POM/4.0.0"
......@@ -105,7 +105,7 @@
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<org.b3log.latke.version>1.3.6</org.b3log.latke.version>
<org.b3log.latke.version>1.3.7</org.b3log.latke.version>
<servlet.version>3.1.0</servlet.version>
<slf4j.version>1.7.5</slf4j.version>
......@@ -114,6 +114,7 @@
<markdownpapers-core.version>1.4.2</markdownpapers-core.version>
<qiniu.version>7.0.4.1</qiniu.version>
<jetty.version>9.2.13.v20150730</jetty.version>
<commons-cli.version>1.3.1</commons-cli.version>
<!-- maven plugin -->
<maven-compiler-plugin.version>3.3</maven-compiler-plugin.version>
......@@ -206,6 +207,12 @@
<artifactId>jetty-webapp</artifactId>
<version>${jetty.version}</version>
</dependency>
<dependency>
<groupId>commons-cli</groupId>
<artifactId>commons-cli</artifactId>
<version>${commons-cli.version}</version>
</dependency>
<!-- BEGIN: GAE related dependencies just for testing -->
<dependency>
......
......@@ -19,6 +19,10 @@ import java.awt.Desktop;
import java.io.File;
import java.net.URI;
import java.util.ResourceBundle;
import org.apache.commons.cli.CommandLine;
import org.apache.commons.cli.CommandLineParser;
import org.apache.commons.cli.DefaultParser;
import org.apache.commons.cli.Options;
import org.b3log.latke.logging.Logger;
import org.b3log.latke.util.Strings;
import org.eclipse.jetty.server.Server;
......@@ -35,7 +39,7 @@ import org.eclipse.jetty.webapp.WebAppContext;
* </ul>
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.0.0.2, Oct 31, 2015
* @version 1.0.0.3, Nov 29, 2015
* @since 1.2.0
*/
public final class Starter {
......@@ -57,18 +61,29 @@ public final class Starter {
public static void main(final String[] args) throws Exception {
final Logger logger = Logger.getLogger(Starter.class);
final Options options = new Options();
options.addOption("p", "port", true, "listen port");
final CommandLineParser commandLineParser = new DefaultParser();
final CommandLine commandLine = commandLineParser.parse(options, args);
String portArg = commandLine.getOptionValue("p");
if (!Strings.isNumeric(portArg)) {
portArg = "9090";
}
logger.info("Standalone mode, see [https://github.com/b3log/solo/wiki/standalone_mode] for more details.");
String webappDirLocation = "src/main/webapp/"; // POM structure in dev env
final File file = new File(webappDirLocation);
if (!file.exists()) {
webappDirLocation = "."; // prod env
webappDirLocation = "."; // production environment
}
final ResourceBundle latke = ResourceBundle.getBundle("latke");
final int port = Integer.valueOf(portArg);
final int port = Integer.valueOf(latke.getString("serverPort"));
final ResourceBundle latke = ResourceBundle.getBundle("latke");
String contextPath = latke.getString("contextPath");
if (Strings.isEmptyOrNull(contextPath)) {
contextPath = "/";
......@@ -89,9 +104,10 @@ public final class Starter {
final String host = latke.getString("serverHost");
try {
Desktop.getDesktop().browse(new URI(scheme + "://" + host + ":" + port + contextPath));
final int visitPort = Integer.valueOf(latke.getString("serverPort"));
Desktop.getDesktop().browse(new URI(scheme + "://" + host + ":" + visitPort + contextPath));
} catch (final Throwable e) {
e.printStackTrace();
// Ignored
}
server.join();
......
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