2

My game server has a custom PHP administration interface, which can run the server manually by running the start shell script with exec and sudo -E. However, if I restart httpd using service httpd restart, both the script and the actual game server get killed, too. How can I change this behaviour so that only the web server get killed, or run the game server some other way?

1

I used to solve exactly this problem for my game servers by writing a perl daemon that owned and controlled gameservers, and answered ad a web service to outer world. Simply put, but effective.

1

When you access the web-page (PHP script), the content is sent by one instance (sub-process) of the httpd server process. When you restart the httpd server, the script is informing the server to die, which will kill all the sub-processes too, including the PHP instance running the script itself. Basically the script is effectively committing suicide.

Try using "apachectl -k graceful" which will restart the server gracefully, meaning only server process will be restarted, but current sessions will be allowed to complete. Your script should not die.

  • It would be more clear to say php is a module⁄child then using a vague "it is coming" – Rui F Ribeiro Jan 16 '16 at 13:25
  • Using graceful restart will DoS your service : no new connections will be accepted and served until all the childs(gameservers) will exit – Alexey Vesnin Jan 16 '16 at 14:43
  • @AlexeyVesnin , when using "graceful", new gameservers will start, but old gameservers will not be killed. – Prem Jan 16 '16 at 16:33
  • 1
    @Prem as far as I remember the manual : The USR1 or graceful signal causes the parent process to advise the children to exit after their current request (or to exit immediately if they're not serving anything). The parent re-reads its configuration files and re-opens its log files. As each child dies off the parent replaces it with a child from the new generation of the configuration, which begins serving new requests immediately. – Alexey Vesnin Jan 16 '16 at 16:35
  • 1
    @RuiFRibeiro , based on your feedback , I have made a slight change in wording. – Prem Jan 16 '16 at 16:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.