PHP exec hang.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • DragSta
    New Member
    • Mar 2008
    • 2

    #1

    PHP exec hang.

    Hello everyone, im slowly learning PHP and im strarting to kinda get the hang of the basics.
    Basically, i am making a control panel for a Game Server, that can start and stop the server by running the commands './gtaserver.sh start' or './gtaserver.sh stop'.
    I have 2 buttons on my control panel, Star and stop. If the server is running, the Stop button works like a dream, no problems at all and it runs through the rest of the html code in the file where i call exec('./gtaserver.sh stop');.
    Pressing the Start button on the other hand, is VERY annoying. When you press it it appears that it cannot load the page and just hangs. The server starts, but the web page gives a user the impression that it hasnt and they might press the button again. As it hangs, it also stops the rest of the html code (a redirect) working in the file where i call exec('./gtaserver.sh start');.
    I have tried things like './gtaserver start\n echo started' That fixes the html code not running problem, but the server doesnt start.

    Any help on this is greatly apprecieated.

    Thanks,
    DragSta

    PS:
    Server info:
    Redhat Linux Fedora 6
    Apache version 2.2.3
    1 gb ram
  • TheServant
    Recognized Expert Top Contributor
    • Feb 2008
    • 1168

    #2
    What about having a delayed refresh of the page? So you execute the server start and on the next line give a 5 second delayed refresh. That way the serve has time to wake up before it has requests?

    Comment

    • DragSta
      New Member
      • Mar 2008
      • 2

      #3
      Originally posted by TheServant
      What about having a delayed refresh of the page? So you execute the server start and on the next line give a 5 second delayed refresh. That way the serve has time to wake up before it has requests?
      Thanks for the help, but i fixed it anyway. I used popen instead of exec. Works like a dream :D

      Heres the code i used:
      Code:
      $fp=popen("./gtaserver start","r");

      Comment

      Working...