Code for stopping the server

Options
vitorcmaia
edited August 2012 in Photon Server
When I want to stop the server, I write "start PhotonSocketServer.exe /stop Instance" in the Command Prompt. Is there a way of doing it using Photon, instead of manually? Something like a "Drop Server" function.

Comments

  • Tobias
    Options
    You mean like an operation to stop Photon?
    No, there is none.
    You could add one, if you needed to, cause in the server code, you can start any process and also call "PhotonSocketServer.exe /stop Instance".
  • Thanks Tobias, I created an Operation, as you said.
    This operation triggers a method which creates a process. This process calls a batch file in the server computer, and inside this batch I call the "/stop Instance" command.
    But I think that this implementation may not be so sturdy. The total time for a 'stop' to happen varies from milliseconds to some seconds , and I can't detect this precise interval.

    I wonder if I can wait some time using Photon instead of a batch file. Can I manage this time using Server2Server? Can I change any other step from my implementation using Server2Server?
  • dreamora
    Options
    You could use the process to run a distinct app you put side by side to the photon installation.
    make this app wait for the service process (photonsocketserver) to go down, do whatever it is meant to do and then start up again.

    And no, you can not use Server2Server as it only exists while photon applications are running.
    There is no management layer to control the existance and running of the photon instance from the outside beside the process command line argument above and the os level service controls which are even slower
  • Tobias
    Options
    Where do you need the info if a server is stopped or not?
    Photon Control also checks the process and services lists to check if Photon is running or not.
    If you want to restart Photon after shutting it down, you will need a separate service running anyways. You can't reach and start a shutdown Photon directly.
  • Thanks for the help, I managed to do what I wanted.
    My intention was to reset the server before every test, and it runs in a different computer.