0

On the command line, after entering play run, there are a few ways that I have read about stopping the play server:

  1. You can press Ctrl+ D
  2. You can send a SIGTERM to the process, based off of the RUNNING_PID (in production).
  3. In Windows, you can manually kill the Java processes running (on the commandline probably with taskkill.

The problem is that #1 requires you to be on the same console, #2 requires you to know the process ID (which doesn't get written to a file in the development environment), and #3 can stop more than just the server.

Is there a way to kill a Play server in a non-production / development environment from another console (on Windows 7 or Windows 8)? Ideally, something like Ctrl+ D, but from a different console?

Community
  • 1
  • 1
rishimaharaj
  • 1,644
  • 2
  • 19
  • 34

1 Answers1

0

No... you can't kill app from other console, but you can maintain your own pid file, i.e. using Global object:

import org.apache.commons.io.FileUtils;
import play.Application;
import play.GlobalSettings;
import play.Play;

import java.io.File;
import java.io.IOException;
import java.lang.management.ManagementFactory;

public class Global extends GlobalSettings {


    @Override
    public void beforeStart(Application app) {
        if (!Play.isProd()) {
            try {
                FileUtils.writeStringToFile(new File("DEVELOPMENT_PID"), ManagementFactory.getRuntimeMXBean().getName().split("@")[0]);
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
}

Note, that will be saved/updated AFTER first request... I didn't test it on Windows

Other, more comfortable way for starting/stopping dev application is using i.e.: Intellij Idea with Play support, when Run Configuration is done correctly you can do that just with buttons/shortcuts within IDE.

Finally you can just try to search process in TaskManager by name and then stop it there

biesior
  • 55,576
  • 10
  • 125
  • 182