Commits

Sebastian Sdorra  committed dd7799e

fix open webserver port < 1024 as non privileged user

  • Participants
  • Parent commits a7fbe3f
  • Branches 1.x

Comments (0)

Files changed (2)

File scm-server/src/main/java/sonia/scm/server/ScmServer.java

   {
     try
     {
+      if (!initialized)
+      {
+        server.join();
+      }
+
       server.start();
-      server.join();
     }
     catch (Exception ex)
     {
-      throw new RuntimeException(ex);
+      if (ex instanceof ScmServerException)
+      {
+        throw(ScmServerException) ex;
+      }
+      else
+      {
+        throw new ScmServerException("could not start scm-server", ex);
+      }
     }
   }
 
     try
     {
       server.setStopAtShutdown(true);
+      initialized = false;
     }
     catch (Exception ex)
     {
     }
   }
 
+  /**
+   * Method description
+   *
+   */
+  void init()
+  {
+    try
+    {
+      server.start();
+      initialized = true;
+    }
+    catch (Exception ex)
+    {
+      throw new ScmServerException("could not initialize server", ex);
+    }
+  }
+
   //~--- fields ---------------------------------------------------------------
 
   /** Field description */
+  private boolean initialized = false;
+
+  /** Field description */
   private Server server = new Server();
 }

File scm-server/src/main/java/sonia/scm/server/ScmServerDaemon.java

   public void init(DaemonContext context) throws DaemonInitException, Exception
   {
     daemonArgs = context.getArguments();
+    // initialize web server and open port. We have to do this in the init 
+    // method, because this method is started by jsvc with super user privileges.
+    webserver.init();
   }
 
   /**