2020-03-23 15:35:58 +01:00
|
|
|
/*
|
|
|
|
|
* MIT License
|
2010-10-31 19:22:53 +01:00
|
|
|
*
|
2020-03-23 15:35:58 +01:00
|
|
|
* Copyright (c) 2020-present Cloudogu GmbH and Contributors
|
2010-10-31 19:22:53 +01:00
|
|
|
*
|
2020-03-23 15:35:58 +01:00
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
|
* of this software and associated documentation files (the "Software"), to deal
|
|
|
|
|
* in the Software without restriction, including without limitation the rights
|
|
|
|
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
|
* copies of the Software, and to permit persons to whom the Software is
|
|
|
|
|
* furnished to do so, subject to the following conditions:
|
2010-10-31 19:22:53 +01:00
|
|
|
*
|
2020-03-23 15:35:58 +01:00
|
|
|
* The above copyright notice and this permission notice shall be included in all
|
|
|
|
|
* copies or substantial portions of the Software.
|
2010-10-31 19:22:53 +01:00
|
|
|
*
|
2020-03-23 15:35:58 +01:00
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
|
|
|
* SOFTWARE.
|
2010-09-11 17:59:11 +02:00
|
|
|
*/
|
2020-03-23 15:35:58 +01:00
|
|
|
|
2011-03-02 19:26:48 +01:00
|
|
|
package sonia.scm.server;
|
|
|
|
|
|
|
|
|
|
//~--- non-JDK imports --------------------------------------------------------
|
2010-09-11 17:59:11 +02:00
|
|
|
|
2011-03-02 19:26:48 +01:00
|
|
|
import org.apache.commons.daemon.Daemon;
|
|
|
|
|
import org.apache.commons.daemon.DaemonContext;
|
|
|
|
|
import org.apache.commons.daemon.DaemonInitException;
|
2010-09-11 17:59:11 +02:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
*
|
|
|
|
|
* @author Sebastian Sdorra
|
|
|
|
|
*/
|
2011-03-02 19:26:48 +01:00
|
|
|
public class ScmServerDaemon implements Daemon
|
2010-09-11 17:59:11 +02:00
|
|
|
{
|
|
|
|
|
|
2011-03-02 19:26:48 +01:00
|
|
|
/** Field description */
|
|
|
|
|
private static volatile ScmServer webserver = new ScmServer();
|
|
|
|
|
|
|
|
|
|
//~--- methods --------------------------------------------------------------
|
|
|
|
|
|
2010-09-11 17:59:11 +02:00
|
|
|
/**
|
2011-03-02 19:26:48 +01:00
|
|
|
* Method description
|
2010-09-11 17:59:11 +02:00
|
|
|
*
|
|
|
|
|
*
|
2011-03-02 19:26:48 +01:00
|
|
|
* @param args
|
2010-09-11 17:59:11 +02:00
|
|
|
*/
|
2011-03-02 19:26:48 +01:00
|
|
|
public static void main(String[] args)
|
2010-09-11 17:59:11 +02:00
|
|
|
{
|
2011-03-02 19:26:48 +01:00
|
|
|
webserver.run();
|
2010-09-11 17:59:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Method description
|
|
|
|
|
*
|
|
|
|
|
*
|
2011-03-02 19:26:48 +01:00
|
|
|
* @param args
|
|
|
|
|
*
|
|
|
|
|
* @throws Exception
|
2010-09-11 17:59:11 +02:00
|
|
|
*/
|
2011-03-02 19:26:48 +01:00
|
|
|
public static void start(String[] args) throws Exception
|
2010-09-11 17:59:11 +02:00
|
|
|
{
|
2011-03-02 19:26:48 +01:00
|
|
|
webserver.start();
|
2010-09-11 17:59:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Method description
|
|
|
|
|
*
|
|
|
|
|
*
|
2011-03-02 19:26:48 +01:00
|
|
|
* @param args
|
|
|
|
|
*
|
|
|
|
|
* @throws Exception
|
2010-09-11 17:59:11 +02:00
|
|
|
*/
|
2011-03-02 19:26:48 +01:00
|
|
|
public static void stop(String[] args) throws Exception
|
2010-09-11 17:59:11 +02:00
|
|
|
{
|
2011-03-02 19:26:48 +01:00
|
|
|
webserver.stopServer();
|
2014-08-28 09:03:43 +02:00
|
|
|
webserver.join((long) ScmServer.GRACEFUL_TIMEOUT);
|
2010-09-11 17:59:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Method description
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
2011-03-02 19:26:48 +01:00
|
|
|
public void destroy()
|
2010-09-11 17:59:11 +02:00
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// do nothing
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Method description
|
|
|
|
|
*
|
|
|
|
|
*
|
2011-03-02 19:26:48 +01:00
|
|
|
* @param context
|
|
|
|
|
*
|
|
|
|
|
* @throws DaemonInitException
|
|
|
|
|
* @throws Exception
|
2010-09-11 17:59:11 +02:00
|
|
|
*/
|
|
|
|
|
@Override
|
2011-03-02 19:26:48 +01:00
|
|
|
public void init(DaemonContext context) throws DaemonInitException, Exception
|
2010-09-11 17:59:11 +02:00
|
|
|
{
|
2011-03-02 19:26:48 +01:00
|
|
|
daemonArgs = context.getArguments();
|
2014-08-28 09:03:43 +02:00
|
|
|
|
|
|
|
|
// initialize web server and open port. We have to do this in the init
|
2014-05-16 13:14:26 +02:00
|
|
|
// method, because this method is started by jsvc with super user privileges.
|
|
|
|
|
webserver.init();
|
2010-09-11 17:59:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Method description
|
|
|
|
|
*
|
|
|
|
|
*
|
2011-03-02 19:26:48 +01:00
|
|
|
* @throws Exception
|
2010-09-11 17:59:11 +02:00
|
|
|
*/
|
|
|
|
|
@Override
|
2011-03-02 19:26:48 +01:00
|
|
|
public void start() throws Exception
|
2010-09-11 17:59:11 +02:00
|
|
|
{
|
2011-03-02 19:26:48 +01:00
|
|
|
start(daemonArgs);
|
|
|
|
|
}
|
2010-09-11 17:59:11 +02:00
|
|
|
|
2011-03-02 19:26:48 +01:00
|
|
|
/**
|
|
|
|
|
* Method description
|
|
|
|
|
*
|
|
|
|
|
*
|
|
|
|
|
* @throws Exception
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
public void stop() throws Exception
|
|
|
|
|
{
|
|
|
|
|
stop(daemonArgs);
|
2010-09-11 17:59:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//~--- fields ---------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
/** Field description */
|
2011-03-02 19:26:48 +01:00
|
|
|
private String[] daemonArgs;
|
2010-09-11 17:59:11 +02:00
|
|
|
}
|