ripper234
ripper234

Reputation: 230156

What is the equivalent to 'play stop' for Play Framework 2.1?

What is the equivalent of play stop for Play 2.1?

If I did play start, how do I cleanly terminate the process?

Upvotes: 16

Views: 16016

Answers (7)

Benj
Benj

Reputation: 1204

You can call <your_server_url>/@kill , e.g. : http://localhost:9022/app3/@kill

Upvotes: 0

Saeed Zarinfam
Saeed Zarinfam

Reputation: 10190

You can run this script:

kill $(cat /your-play-project-path/target/universal/stage/RUNNING_PID)

Upvotes: 10

John Kentucky
John Kentucky

Reputation: 886

To achieve this, you could modify the build.sbt file as described here.

TaskKey[Unit]("stop") := {
  val pidFile = target.value / "universal" / "stage" / "RUNNING_PID"
  if (!pidFile.exists) throw new Exception("App not started!")
  val pid = IO.read(pidFile)
  s"kill $pid".!
  println(s"Stopped application with process ID $pid")
}

However, this only applies to *nix systems.

Upvotes: 0

tehlexx
tehlexx

Reputation: 2859

On Windows I'm using the following script to kill the currently running play server

@echo off
if exist RUNNING_PID (
  setlocal EnableDelayedExpansion
  set /p PLAY_PID=<RUNNING_PID
  echo killing pid !PLAY_PID!
  taskkill /F /PID !PLAY_PID!
  del RUNNING_PID
  endlocal
) 

Upvotes: 18

disperse
disperse

Reputation: 1294

Simply press Ctrl + D in the console window.

Upvotes: 0

ndeverge
ndeverge

Reputation: 21564

As stated in the doc:

When you run the start command, Play forks a new JVM and runs the default Netty HTTP server. The standard output stream is redirected to the Play console, so you can monitor its status.

The server’s process id is displayed at bootstrap and written to the RUNNING_PID file. To kill a running Play server, it is enough to send a SIGTERM to the process to properly shutdown the application.

If you type Ctrl+D, the Play console will quit, but the created server process will continue running in background. The forked JVM’s standard output stream is then closed, and logging can be read from the logs/application.log file.

So I think that you have to use play run instead of play start. Then you'll be able to use Ctrl+D to stop play.

Upvotes: 12

Michael Hawkins
Michael Hawkins

Reputation: 2873

If you ran your app using the play start command, issuing the play stop command from the app directory does work and will stop the running application server.

I verified this works in Play 2.1.1.

Upvotes: 8

Related Questions