コード例 #1
0
  @Override
  public void launch() {
    // TODO if can't be root, and ports > 1024 are in the allowed port range,
    // prefer that; could do this on SshMachineLocation which implements PortSupplier,
    // invoked from PortAttrSensorAndConfigKey, which is invoked from
    // MachineLifecycleTasks.preStartCustom
    Networking.checkPortsValid(MutableMap.of("httpPort", getHttpPort()));

    // We wait for evidence of running because, using
    // brooklyn.ssh.config.tool.class=brooklyn.util.internal.ssh.cli.SshCliTool,
    // we saw the ssh session return before the tomcat process was fully running
    // so the process failed to start.
    newScript(MutableMap.of("usePidFile", false), LAUNCHING)
        .body
        .append(
            format("cd %s", getRunDir()),
            BashCommands.requireExecutable("./sbin/nginx"),
            sudoBashCIfPrivilegedPort(
                getHttpPort(),
                format(
                    "nohup ./sbin/nginx -p %s/ -c conf/server.conf > %s 2>&1 &",
                    getRunDir(), getLogFileLocation())),
            format(
                "for i in {1..10}\n"
                    + "do\n"
                    + "    test -f %1$s && ps -p `cat %1$s` && exit\n"
                    + "    sleep 1\n"
                    + "done\n"
                    + "echo \"No explicit error launching nginx but couldn't find process by pid; continuing but may subsequently fail\"\n"
                    + "cat %2$s | tee /dev/stderr",
                getPidFile(), getLogFileLocation()))
        .execute();
  }
コード例 #2
0
 @BeforeMethod(alwaysRun = true)
 public void setUp() throws Exception {
   managementContext = new LocalManagementContext();
   host =
       managementContext
           .getLocationManager()
           .createLocation(
               LocationSpec.create(SshMachineLocation.class)
                   .configure("address", Networking.getLocalHost())
                   .configure(SshTool.PROP_TOOL_CLASS, RecordingSshjTool.class.getName()));
 }
コード例 #3
0
 public Map<String, Object> customSshConfigKeys() throws UnknownHostException {
   return MutableMap.<String, Object>of(
       "address",
       Networking.getLocalHost(),
       SshTool.PROP_SESSION_TIMEOUT.getName(),
       20000,
       SshTool.PROP_CONNECT_TIMEOUT.getName(),
       50000,
       SshTool.PROP_SCRIPT_HEADER.getName(),
       "#!/bin/bash");
 }
コード例 #4
0
 public CalculatedStatus() {
   HostAndPort endpoint = getConfig(ENDPOINT);
   connected = Networking.isReachable(endpoint);
 }