Page 1 of 1

Restart extension by REST

Posted: 11 Aug 2017, 07:02
by NickNick
My Smartfox installation is planned to host multiple zones, each zone dedicated to corresponding application.

Now I'm trying to create deploy scripts for each extension, avoiding unnecessary details, it will be like "Take this jar and copy it to its folder in Smartfox, copy zone settings, nice, now reload the extension".
And there is a problem with the last step - I don't see the proper way to do this automatically.
It can be achieved easily by manually clicking "Reload" button at admin tool, but it's unacceptable way for my deployment.

So, basically, I just want to "press" "Reload" button programmatically, is there any way to do this?

P.S.
Also tried entering --=={{{ AdminZone }}}==--, but got

Code: Select all

INFO  [SocketReader] sessions.DefaultSessionManager     - Session created: { Id: 6, Type: DEFAULT, Logged: No, IP: 127.0.0.1:33490 } on Server port: 9933 <---> 33490
WARN  [SFSWorker:Ext:1] managers.SFSExtensionManager     - java.lang.NullPointerException:
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
Exception: java.lang.NullPointerException
Message: *** Null ***
Description: Error during event handling: java.lang.NullPointerException, Listener: { Ext: Admin, Type: JAVA, Lev: ZONE, { Zone: --=={{{ AdminZone }}}==-- }, {} }
+--- --- ---+
Stack Trace:
+--- --- ---+
com.smartfoxserver.v2.admin.handlers.events.LoginEvtHandler.handleServerEvent(LoginEvtHandler.java:97)
com.smartfoxserver.v2.extensions.SFSExtension.handleServerEvent(SFSExtension.java:259)
com.smartfoxserver.v2.entities.managers.SFSExtensionManager.dispatchEvent(SFSExtensionManager.java:768)
com.smartfoxserver.v2.entities.managers.SFSExtensionManager.dispatchZoneLevelEvent(SFSExtensionManager.java:689)
com.smartfoxserver.v2.entities.managers.SFSExtensionManager.handleServerEvent(SFSExtensionManager.java:887)

Re: Restart extension by REST

Posted: 11 Aug 2017, 08:14
by Lapo
You could simply use the auto-reload mode in your Zone(s).
When file is copied the Extension will auto-restart. The only caveat with this approach is that remote uploads won't work, because they are too slow and the system will detect that the file has been overwritten when it's not yet completely done.

Since you're using HTTP I suppose you are uploading the file first and then copy it to the right folder, so it should work fine.

Hope it helps

Re: Restart extension by REST

Posted: 12 Aug 2017, 05:56
by NickNick
Thank you.
Didn't wanna risk with auto-reload, so it was the last option.

If someone will ever have same question: I've somehow missed the obvious way "SmartFoxServer.getInstance().getExtensionManager().reloadExtension(zone.getExtension())".
So just need to add HTTP endpoint with this call (I already have custom http server inside Smartfox) or an auxiliary extension.