Exemplo n.º 1
0
 private ILaunch launchPeer(final BackendData data) {
   final ILaunchConfiguration launchConfig = data.asLaunchConfiguration();
   try {
     final boolean registerForDebug =
         data.getLaunch() != null || SystemConfiguration.getInstance().isDeveloper();
     return launchConfig.launch(
         ILaunchManager.RUN_MODE, new NullProgressMonitor(), false, registerForDebug);
   } catch (final CoreException e) {
     ErlLogger.error(e);
     return null;
   }
 }
Exemplo n.º 2
0
 @Override
 public boolean isValid(final ILaunchConfiguration config) {
   setErrorMessage(null);
   final String name = nameText.getText().trim();
   if (!name.equals("") && !BackendData.validateNodeName(name)) {
     setErrorMessage(String.format("Node name '%s' is invalid.", name));
     return false;
   }
   String workingDir = workingDirText.getText();
   File d = new File(workingDir);
   if (d.isAbsolute()) {
     if (!d.exists()) {
       setErrorMessage(String.format("Working dir '%s' doesn't exist.", workingDir));
       return false;
     }
   } else {
     final String wspace =
         ResourcesPlugin.getWorkspace().getRoot().getLocation().toPortableString();
     workingDir = wspace + "/" + workingDir;
     d = new File(workingDir);
     if (!d.exists()) {
       setErrorMessage(String.format("Working dir '%s' doesn't exist.", workingDir));
       return false;
     }
   }
   return true;
 }
Exemplo n.º 3
0
 private BackendData getIdeBackendData() {
   final RuntimeInfo info = getIdeRuntimeInfo();
   final BackendData result = new BackendData(runtimeInfoManager, info);
   result.setNodeName(getIdeNodeName());
   result.setDebug(false);
   result.setAutostart(true);
   result.setConsole(false);
   result.setLongName(HostnameUtils.canUseLongNames());
   if (SystemConfiguration.getInstance().isDeveloper()) {
     result.setConsole(true);
   }
   if (SystemConfiguration.getInstance().isMonitoringIdeBackend()) {
     result.setMonitored(true);
   }
   result.setInternal(true);
   return result;
 }
Exemplo n.º 4
0
  private BackendData getBuildBackendData(final RuntimeInfo info) {
    final RuntimeInfo myinfo = RuntimeInfo.copy(info, false);

    final BackendData result = new BackendData(runtimeInfoManager, myinfo);
    result.setNodeName(
        info.getVersion().asMajor().toString() + "_" + BackendUtils.getErlideNodeNameTag());
    result.setCookie("erlide");
    result.setDebug(false);
    result.setAutostart(true);
    result.setConsole(false);
    result.setLongName(HostnameUtils.canUseLongNames());
    result.setInternal(true);
    return result;
  }
Exemplo n.º 5
0
  @Override
  public IBackend createBackend(final BackendData data) {
    ErlLogger.debug("Create backend " + data.getNodeName());
    if (!data.isManaged() && !data.isAutostart()) {
      ErlLogger.info("Not creating backend for %s", data.getNodeName());
      return null;
    }

    final IBackend b;
    final String erlangHostName = HostnameUtils.getErlangHostName(data.isLongName());
    try {
      String nodeName = data.getNodeName();
      final boolean hasHost = nodeName.contains("@");
      nodeName = hasHost ? nodeName : nodeName + "@" + erlangHostName;
      ILaunch launch = data.getLaunch();
      if (launch == null) {
        launch = launchPeer(data);
      }
      final IProcess mainProcess =
          launch.getProcesses().length == 0 ? null : launch.getProcesses()[0];
      final IErlRuntime runtime =
          new ErlRuntime(
              nodeName, data.getCookie(), mainProcess, !data.isTransient(), data.isLongName());
      b =
          data.isInternal()
              ? new InternalBackend(data, runtime)
              : new ExternalBackend(data, runtime);
      b.initialize();
      return b;
    } catch (final BackendException e) {
      e.printStackTrace();
    }
    return null;
  }