[2.0] Global.onStop is not invoked.

342 views
Skip to first unread message

Justin

unread,
Apr 19, 2012, 4:03:01 AM4/19/12
to play-fr...@googlegroups.com
Hi!

I need to do tasks when the process is killed.
So I simply did the instruction from the wiki, https://github.com/playframework/Play20/wiki/ScalaGlobal

But it simply does not work.
Help me, please.

Thanks, 
Justin

Leonard Punt

unread,
Apr 19, 2012, 5:01:29 AM4/19/12
to play-fr...@googlegroups.com
Do you 'kill' your application or do you 'shut it down'? Because, I think, it makes sense Global.onStop is not invoked when you kill your process.

Leonard

Op donderdag 19 april 2012 10:03:01 UTC+2 schreef Justin het volgende:

Justin

unread,
Apr 19, 2012, 5:05:00 AM4/19/12
to play-fr...@googlegroups.com
I did 'kill' using 'play stop'.

Then, how do I 'shut down'?

Thanks for the reply, Leonard.

2012년 4월 19일 목요일 오후 6시 1분 29초 UTC+9, Leonard Punt 님의 말:

Leonard Punt

unread,
Apr 19, 2012, 5:11:54 AM4/19/12
to play-fr...@googlegroups.com
Okay, with killing I ment: 'kill -9 <pid>' or something like that. If you used 'play stop' it should do a normal 'shutdown' and it should invoke Global.onStop. It sounds like a bug. I can't help you any further right now, hopefully someone else can.

Leonard

Op donderdag 19 april 2012 11:05:00 UTC+2 schreef Justin het volgende:

Justin

unread,
Apr 19, 2012, 9:49:39 PM4/19/12
to play-fr...@googlegroups.com
This question is still open.
somebody help me~!

2012년 4월 19일 목요일 오후 6시 11분 54초 UTC+9, Leonard Punt 님의 말:

Julien Richard-Foy

unread,
Apr 20, 2012, 6:02:45 AM4/20/12
to play-fr...@googlegroups.com
It should work, maybe there is a bug. Please file a ticket in the tracker.

Justin

unread,
Apr 20, 2012, 6:05:42 AM4/20/12
to play-fr...@googlegroups.com
To resolve the problem, I have read through the source codes of Play framework 2.

It does not seem that the framework always call the 'onStop'
'onStop' is called only if the application runs with the command 'play run' and it's stopped by pressing CTRL + D.

As of version 2.0, in order to do something before the application stops, you need to use 'Runtime.getRuntime.addShutdownHook'.

It is the way that the play framework deletes the 'RUNNING_ID' file.
(see src/main/scala/play/core/server/NettyServer.scala)

You may get more information on 'addShutdownHook' from the below link.
http://blog.stefandeboey.be/riding-the-scala-wave

It'd be very helpful if the committers confirm this.


2012년 4월 20일 금요일 오전 10시 49분 39초 UTC+9, Justin 님의 말:

Justin

unread,
Apr 20, 2012, 6:14:35 AM4/20/12
to play-fr...@googlegroups.com
thanks for confirming, Julien.
I just issued the ticket.

2012년 4월 20일 금요일 오후 7시 2분 45초 UTC+9, Julien Richard-Foy 님의 말:
Reply all
Reply to author
Forward
0 new messages