Restart extension by REST

Post here your questions about SFS2X. Here we discuss all server-side matters. For client API questions see the dedicated forums.

Moderators: Lapo, Bax

Posts: 6
Joined: 13 Jul 2017, 09:30

Restart extension by REST

Postby NickNick » 11 Aug 2017, 07:02

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?

Also tried entering --=={{{ AdminZone }}}==--, but got

Code: Select all

INFO  [SocketReader] sessions.DefaultSessionManager     - Session created: { Id: 6, Type: DEFAULT, Logged: No, IP: } 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:
+--- --- ---+
User avatar
Site Admin
Posts: 20100
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Restart extension by REST

Postby Lapo » 11 Aug 2017, 08:14

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
...addicted to flash games
Posts: 6
Joined: 13 Jul 2017, 09:30

Re: Restart extension by REST

Postby NickNick » 12 Aug 2017, 05:56

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.

Return to “SFS2X Questions”

Who is online

Users browsing this forum: No registered users and 11 guests