Example #1
0
  public ServerResult start(ServerParameters rawParams) throws Exception {
    AppServerParameters params = (AppServerParameters) rawParams;
    instanceDir = createInstance(params);

    instanceDir.delete(); // createDomain will fail if directory already exists
    createDomain(params);

    modifyDomainConfig(params);

    setProperties(params, httpPort, instanceDir);

    final String cmd[] = getStartupCommand(params);
    final String nodeLogFile =
        new File(instanceDir.getParent(), instanceDir.getName() + ".log").getAbsolutePath();

    runner =
        new Thread("runner for " + params.instanceName()) {
          public void run() {
            try {
              Result result = Exec.execute(cmd, nodeLogFile, startupInput(), instanceDir);
              if (result.getExitCode() != 0) {
                System.err.println(result);
              }
            } catch (Throwable e) {
              e.printStackTrace();
            }
          }
        };
    runner.start();
    System.err.println("Starting " + params.instanceName() + " on port " + httpPort + "...");

    AppServerUtil.waitForPort(adminPort, START_STOP_TIMEOUT);

    System.err.println("Started " + params.instanceName() + " on port " + httpPort);

    deployWars(params.wars());

    return new AppServerResult(httpPort, this);
  }
Example #2
0
  private void createDomain(AppServerParameters params) throws Exception {
    File asAdminScript = getAsadminScript();

    List cmd = new ArrayList();
    cmd.add(asAdminScript.getAbsolutePath());
    cmd.add("create-domain");
    cmd.add("--interactive=false");
    cmd.add("--domaindir=" + sandboxDirectory());
    cmd.add("--adminport");
    cmd.add(String.valueOf(adminPort));
    cmd.add("--adminuser");
    cmd.add(ADMIN_USER);
    cmd.add("--passwordfile");
    cmd.add(getPasswdFile().getAbsolutePath());
    cmd.add("--instanceport");
    cmd.add(String.valueOf(httpPort));
    cmd.add("--savemasterpassword=true");
    cmd.add("--domainproperties");
    cmd.add(
        "jms.port="
            + pc.chooseRandomPort()
            + ":"
            + "orb.listener.port="
            + pc.chooseRandomPort()
            + ":"
            + "http.ssl.port="
            + pc.chooseRandomPort()
            + ":"
            + "orb.ssl.port="
            + pc.chooseRandomPort()
            + ":"
            + "orb.mutualauth.port="
            + pc.chooseRandomPort()
            + ":"
            + "domain.jmxPort="
            + pc.chooseRandomPort());
    cmd.add("--savelogin=true");
    cmd.add(params.instanceName());

    Result result =
        Exec.execute(
            (String[]) cmd.toArray(new String[] {}), null, null, asAdminScript.getParentFile());

    if (result.getExitCode() != 0) {
      throw new RuntimeException(result.toString());
    }
  }