When does server.sh/php run?

Discussion in 'Developers' Forum' started by zabersoft, Aug 27, 2010.

  1. zabersoft

    zabersoft Member

    Alright, this might seem like a stupid question - but let me explain ...

    We are using ISPCP automation to set up a hosting environment where users can easily set up an account and get some default web applications available in their web root - all set up ready to go.

    I saw the other thread where a guy was asking about pretty much the same I am here - and there till showed some nice example code on how to extend server.php to run some code whenever it was done doing its work - which then could be used to copy files to the users web root.

    I have not explored this approach myself yet - as I have a more fundamental problem/question on my mind:

    When the heck does server.php run? The Cron entry makes little sense to me - and it seems pretty random when it is invoked on my server. Sometimes directories pop up within seconds - sometimes it takes as much as 5 to 10 minutes before web directories are created.

    Furthermore - invoking server.sh manually has varied results. Sometimes I get the "finished." message. Sometimes nothing. Sometimes I get the updating message - but still no new directories. Then they magically appear minutes later.

    Logging seems to be broken as well - I have edited the config file and set debug level to 0 and looked through the code closely - but still nothing makes it to my log file. This makes me suspect something bad is going on...

    As you can expect, this is leaving me somewhat confused. The thing is, we are building our system as a wizard type of thing at the end of which we want to take the user to their new site immediatly - So time is an issue here.

    If your answer is: Your system is effed up - reinstall and try again - Then I'd say: Alright, fine, I kind of expected that answer :)
  2. till

    till Super Moderator Staff Member ISPConfig Developer

    The server.php script runs exactly once a minute.

    Then you might have some kind of addon or custom code in your setup which has an error and might block the action queue. To check out what is going on, enable debugging:


    By the way, ISPCP is not ISPConfig! ISPCP is a software from a different company. But I guess you are talking about ISPConfig here.
    Last edited: Aug 27, 2010
  3. zabersoft

    zabersoft Member

    Whoops sorry

    Hey till!

    Sorry about the ISPCP thing - I get confused with acronyms sometimes - haha. BTW: ISPConfig is much (much!) better than ISPCP! ;-)

    I had of course not noticed the new server setting which enables debugging - which of course explains why I wasnt seeing anything in my log - I'll enable that and continue my tests here and see if I cant track down the cause of my issue.

    If I can just get server.php to create directories reliably when I manually invoke it then I'll be a happy camper. I'll update this thread if I find any relevant results.

    Thanks again till - I can't begin to explain how much I appreciate the fine work you guys are doing.
  4. zabersoft

    zabersoft Member

    Problem tracked down

    Alright, after having enabled debugging properly then the issue was easy to track down

    All this weirdness with varying times that server.php was being invoked was due to me messing things up (of course)

    I was manually invoking server.sh via php and this made the server.php script hang due to improper permissions ("unable to open logfile" was the error)

    This blocked any other instance of server.php running untill my invoked process stopped running.

    Hence the weirdness. Now I just need to figure out how to start server.sh without any permission problems and I am ready to rock.

    Thanks again for pointing me in the right direction!
  5. till

    till Super Moderator Staff Member ISPConfig Developer

    One additional note, if you run server.sh and you dont get any output at all, then there is most likely a php syntax error in the code. To get the php error output, comment out the line

    ini_set('error_reporting','E_ALL & ~E_NOTICE');

    in server.php.
  6. jwarnier

    jwarnier ISPConfig Developer ISPConfig Developer

    We are probably the company where the "other guy" works.

    I know you probably already figured most of it, but I take this as an opportunity to clearly describe the way it works and link it to tasks in the bugtracker.

    server.sh is really just a wrapper around server.php to set up a $PATH for command-lines executed by server.php and its modules and plugins.
    It is started from root's cronjob every minute.

    I think this server.sh (and cron_daily.sh) should disappear, but it is not a trivial task as long as there are commands like "which awk" executed in the code.
    See http://www.howtoforge.com/forums/showthread.php?t=47801

    If you have some time to spend on this and want to help, you are welcome. Even better if you know some PHP.

    This cronjob is run every minute, and as it is located in root's cronjob, you can read it as root with a "crontab -l" or edit it with a "crontab -e".
    Logging is working perfectly for us.

    I don't think so.
  7. jwarnier

    jwarnier ISPConfig Developer ISPConfig Developer

    Also note we dumbly created something (basic) to easily extend server.php, while there already was the "mods" and "plugins" framework.
    See http://www.howtoforge.com/forums/showthread.php?t=47951.

    Any help to rewrite it as a plugin is welcome (we don't have resource to dedicate on this for the moment).

Share This Page