correct way to shutdown photon server
Options
BesoC
✭✭
What is the correct way to stop Photon server from server code?
0
Comments
-
there is no way to do this0
-
You could run an external task/process, which in turn can tell the server to stop.
The *.cmd files in the server SDK could be called. Look at _service.stop.cmd and _run-Photon-as-application.stop.cmd
Why do you want to do this?0 -
well, i want the server to check some hardware and software conditions and halt if they are not met. The only way i think of is to call AppDomain.Unload(AppDomain.CurrentDomain). If this call is performed in Setup() then it works and server is stopped. However, if it's called from any other part of code, then domain unloads and became re-loaded automatically.0
-
Yes, that makes sense:
If the app domain is unloaded during setup, the app was in fact not loaded successfully - and Photon will not start if it fails to load an application.
You can probably prevent the automatic reloads by setting the ForceAutoRestart="false" and "EnableAutoRestart="false" for each <Application> node in your PhotonServer.config - but this should only leave you with a running Photon instance in which the applications are unloaded; Photon itself will keep running.
The easiest approach is probably to install Photon as a service and call this:var service = ServiceController.GetServices().FirstOrDefault( svc => svc.ServiceName.Equals("Photon Socket Server: Default")); if (service != null && service.Status == ServiceControllerStatus.Running) { service.Stop(); }
0