Page 1 of 1
Running php when server starts
Posted: Tue Mar 31, 2009 9:47 am
by AluminX
Hi, Not sure if this question belongs here...
I have Apache 2.2 and php5 setup localy. I would like to run a certain php function as soon as apache starts.
The function should call in a schema.xml(parse it) and keep it in the memory so that everytime the client makes a call to access the db, the server has the table structure in the memory for fast access.
However i don't know how to initiate such a function as well as how to keep it in the memory.
If anyone can help would be greatly appreciated
Thank you
Re: Running php when server starts
Posted: Tue Mar 31, 2009 11:38 am
by php_east
maybe you can use this, from PHP5 manual....
auto_prepend_file string
Specifies the name of a file that is automatically parsed before the main file. The file is included as if it was called with the include() function, so include_path is used.
Re: Running php when server starts
Posted: Tue Mar 31, 2009 11:57 am
by Mark Baker
For keeping a persistent structure in memory, take a look at PHP's APC module or memcache.
How to execute a script on server startup? Only way I know is manually, though I suppose it would be possible to execute a cron job that does a wget against a server script, which tests to see if the structure is cached, and if nort reads and caches it
Re: Running php when server starts
Posted: Tue Mar 31, 2009 1:17 pm
by php_east
AluminX wrote:The function should call in a schema.xml(parse it) and keep it in the memory so that everytime the client makes a call to access the db, the server has the table structure in the memory for fast access.
isn't this the db/mysql function though ? if the db is started/connected upon php start, that would already put the db in a ready state, no ?
Re: Running php when server starts
Posted: Tue Mar 31, 2009 2:17 pm
by AluminX
Mark Baker wrote:For keeping a persistent structure in memory, take a look at PHP's APC module or memcache.
How to execute a script on server startup? Only way I know is manually, though I suppose it would be possible to execute a cron job that does a wget against a server script, which tests to see if the structure is cached, and if nort reads and caches it
Thanks, i think this is what i actually need.
That's what i'm looking for, how to create a persistent data model.
I'm familiar with the concept but not with the implementation.
Thanks anyway, that should keep me busy until i figure it out
