Hi,
I am running SmartfoxServer 1.6.9 PRO using terracata server. i start sfs server by using start-cluster.sh mentioned in the sfs-terracota clustering doc in this site.
Following is what i do when i need to deploy new code on the server
1. i kill the sfs process
Doing so , the destroy() method of extension is not getting called.
2. ./start-cluster.sh & ( to start the sfs server)
Question: Is there anything which i need to do for the destroy method of extension to be called?
Destroy() of extension not getting called on killing process
-
- Posts: 31
- Joined: 27 Dec 2010, 04:56
Yes, you'll need to halt or reset the server using the AdminTool. It will trigger the destroy function using 'soft' kill approach. Killing the process outside the AdminTool will halt the service immediately which won't give the service a chance to fire the destroy event.
Smartfox's forum is my daily newspaper.
-
- Posts: 31
- Joined: 27 Dec 2010, 04:56
-
- Posts: 8
- Joined: 09 Sep 2016, 16:26
Re: Destroy() of extension not getting called on killing process
Is there any other way that we can trigger the destroy functions (eg. from a shell script)?
Our reboot system relies on sending messages out to the clients warning of an imminent restart, then preventing new games from commencing, and letting any running games finish running before we kill the smartfox server process. This is fully automatic and we can't press the halt button in the AdminTool during this process (no one will be there to do it).
Does destroy do anything else before it calls our user defined extension destroy function?
ie. could we trigger the our own destroy function ourselves during our reboot process, and everything can be expected to be cleaned up correctly (including smartfox's own internal things)?
Our reboot system relies on sending messages out to the clients warning of an imminent restart, then preventing new games from commencing, and letting any running games finish running before we kill the smartfox server process. This is fully automatic and we can't press the halt button in the AdminTool during this process (no one will be there to do it).
Does destroy do anything else before it calls our user defined extension destroy function?
ie. could we trigger the our own destroy function ourselves during our reboot process, and everything can be expected to be cleaned up correctly (including smartfox's own internal things)?
Re: Destroy() of extension not getting called on killing process
Hi,
you could have a special signal for the server that is handled by a custom Extension and which triggers the messages to the clients and the destroy() call in the other running Extensions.
I am just not sure about the part where you say that prevent new games but let the other finish. If the server is being restarted and a destroy() call is being invoked there's no time for games to finish, besides sending an event to clients.
Maybe you don't need to call destroy(), instead you need to create a different signal for your game Extensions that work as described. It denies new games while letting the present ones finish. This is doable by calling handleInternalRequest, which is a way of sending custom signals/method calls across Extensions.
The part that is still not clear is how you restart or kill SFS if it's still managing the ongoing games... that seems tricky although maybe you could detect when there's no more users and issue a restart or halt command from the Extension itself.
hope it helps
you could have a special signal for the server that is handled by a custom Extension and which triggers the messages to the clients and the destroy() call in the other running Extensions.
I am just not sure about the part where you say that prevent new games but let the other finish. If the server is being restarted and a destroy() call is being invoked there's no time for games to finish, besides sending an event to clients.
Maybe you don't need to call destroy(), instead you need to create a different signal for your game Extensions that work as described. It denies new games while letting the present ones finish. This is doable by calling handleInternalRequest, which is a way of sending custom signals/method calls across Extensions.
The part that is still not clear is how you restart or kill SFS if it's still managing the ongoing games... that seems tricky although maybe you could detect when there's no more users and issue a restart or halt command from the Extension itself.
hope it helps
-
- Posts: 8
- Joined: 09 Sep 2016, 16:26
Re: Destroy() of extension not getting called on killing process
Thanks.
The question was just about the cleanup, we only observed recently that the destroy method was not being called and have experienced some strange behaviours relating to Interval timers which seem to not occur if we do a full reboot of the server, versus just stopping and starting the sfs process.
Everything else we already have in place, basically we send out a series of warning messages to the client, 2 minute warnings, 1 minute warning. At a certain point in this process we stop new games from starting, and leave enough time before actually rebooting the server for most conceiveable games to finish (it isn't 100% guaranteed but due to the messages most users have already prepared for the server going down).
Our SFS extension writes a flag file to the filesystem and then a cron job shell script picks up the rest.
Will use the handleInternalEvent method to eventually trigger our destroy function internally to solve this.
The question was just about the cleanup, we only observed recently that the destroy method was not being called and have experienced some strange behaviours relating to Interval timers which seem to not occur if we do a full reboot of the server, versus just stopping and starting the sfs process.
Everything else we already have in place, basically we send out a series of warning messages to the client, 2 minute warnings, 1 minute warning. At a certain point in this process we stop new games from starting, and leave enough time before actually rebooting the server for most conceiveable games to finish (it isn't 100% guaranteed but due to the messages most users have already prepared for the server going down).
Our SFS extension writes a flag file to the filesystem and then a cron job shell script picks up the rest.
Will use the handleInternalEvent method to eventually trigger our destroy function internally to solve this.
Re: Destroy() of extension not getting called on killing process
CaptainHug wrote:Thanks.
The question was just about the cleanup, we only observed recently that the destroy method was not being called and have experienced some strange behaviours relating to Interval timers which seem to not occur if we do a full reboot of the server, versus just stopping and starting the sfs process.
destroy() is called when an Extension is re-deployed. If you restart or stop the server, destroy is not called because the JVM is being turned off. If you want to catch that event (JVM shutting down) there's a Java mechanism called "shutdown hook", which you can google and is pretty simple to use.
Cheers
Return to “SmartFoxServer 1.x Discussions and Help”
Who is online
Users browsing this forum: No registered users and 54 guests