You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
48 lines
1.7 KiB
48 lines
1.7 KiB
package de.srsoftware.widerhall; |
|
|
|
import de.srsoftware.widerhall.data.MailingList; |
|
import de.srsoftware.widerhall.web.Front; |
|
import de.srsoftware.widerhall.web.Rest; |
|
import de.srsoftware.widerhall.web.Web; |
|
import org.eclipse.jetty.server.Connector; |
|
import org.eclipse.jetty.server.Server; |
|
import org.eclipse.jetty.server.ServerConnector; |
|
import org.eclipse.jetty.server.session.SessionHandler; |
|
import org.eclipse.jetty.servlet.ServletContextHandler; |
|
import org.slf4j.Logger; |
|
import org.slf4j.LoggerFactory; |
|
|
|
public class Application { |
|
private static final Logger LOG = LoggerFactory.getLogger(Application.class); |
|
|
|
public static void main(String[] args) throws Exception { |
|
var config = Configuration.instance(); |
|
// the following construct allows the initial config file to point to another config file, which is then loaded: |
|
while (!config.configFile().equals(config.file())) config.load(config.configFile()); |
|
if (!config.configFile().exists()) config.save(); |
|
|
|
|
|
startWebserver(); |
|
startMailsystem(); |
|
} |
|
|
|
private static void startMailsystem() { |
|
MailingList.startEnabled(); |
|
} |
|
|
|
private static void startWebserver() throws Exception { |
|
var config = Configuration.instance(); |
|
var server = new Server(); |
|
var connector = new ServerConnector(server); |
|
connector.setPort(config.serverPort()); |
|
|
|
SessionHandler sh = new SessionHandler(); |
|
server.setConnectors(new Connector[]{connector}); |
|
ServletContextHandler context = new ServletContextHandler(server, "/",sh,null,null,null); |
|
context.addServlet(Rest.class,"/api/*"); |
|
context.addServlet(Web.class,"/web/*"); |
|
context.addServlet(Front.class,"/*"); |
|
|
|
server.start(); |
|
} |
|
}
|
|
|