Пример #1
0
 @NbBundle.Messages({
   "# {0} - project name",
   "InternalWebServer.output.title=Internal WebServer [{0}]"
 })
 private Future<Integer> createProcess() {
   // validate
   PhpInterpreter phpInterpreter;
   try {
     phpInterpreter = PhpInterpreter.getDefault();
   } catch (InvalidPhpExecutableException ex) {
     UiUtils.invalidScriptProvided(ex.getLocalizedMessage());
     return null;
   }
   RunConfigInternal runConfig = RunConfigInternal.forProject(project);
   if (RunConfigInternalValidator.validateCustomizer(runConfig) != null) {
     PhpProjectUtils.openCustomizerRun(project);
     return null;
   }
   // run
   return new PhpExecutable(phpInterpreter.getInterpreter())
       .viaAutodetection(false)
       .viaPhpInterpreter(false)
       .workDir(runConfig.getWorkDir())
       .additionalParameters(getParameters(runConfig))
       .displayName(Bundle.InternalWebServer_output_title(project.getName()))
       .run(getDescriptor());
 }
Пример #2
0
 private List<String> getParameters(RunConfigInternal runConfig) {
   List<String> params = new ArrayList<String>(3);
   params.add(WEB_SERVER_PARAM);
   params.add(runConfig.getServer());
   String relativeDocumentRoot = runConfig.getRelativeDocumentRoot();
   if (relativeDocumentRoot != null) {
     params.add(DOCUMENT_ROOT_PARAM);
     params.add(relativeDocumentRoot);
   }
   String routerRelativePath = runConfig.getRouterRelativePath();
   if (StringUtils.hasText(routerRelativePath)) {
     params.add(routerRelativePath);
   }
   return params;
 }
Пример #3
0
 @NbBundle.Messages({
   "# {0} - project name",
   "InternalWebServer.stopping=Stopping PHP built-in web server for project {0}..."
 })
 @SuppressWarnings("SleepWhileHoldingLock")
 private static boolean ensureServerStopped(InternalWebServer instance) {
   assert !EventQueue.isDispatchThread();
   ProgressHandle progressHandle =
       ProgressHandleFactory.createHandle(
           Bundle.InternalWebServer_stopping(instance.project.getName()));
   try {
     progressHandle.start();
     // stop server
     instance.stop();
     // wait for shutdown
     RunConfigInternal runConfig = RunConfigInternal.forProject(instance.project);
     String host = runConfig.getHostname();
     int port = Integer.valueOf(runConfig.getPort());
     for (int i = 0; i < 20; ++i) {
       try {
         Socket socket = new Socket(host, port);
         socket.close();
         Thread.sleep(200);
       } catch (InterruptedException ex) {
         Thread.currentThread().interrupt();
       } catch (UnknownHostException ex) {
         return true;
       } catch (IOException ex) {
         return true;
       }
     }
     return false;
   } finally {
     progressHandle.finish();
   }
 }