User(s) browsing this thread: 1 Guest(s)
|
PHP Script restart issue
|
|
02-16-2009, 06:22 AM
(This post was last modified: 02-16-2009 06:55 AM by cmgrant.)
|
|||
|
|||
|
PHP Script restart issue
Wondering if anyone can help me with this or at least explain it.
I am running PHP scripts through the interface Code: <a href="http://127.0.0.1:8088/stream/file=/opt/sybhttpd/localhost.drives/HARD_DISK/Video/DMJ/scan.php?">It seems if these scripts take more then a certain amount of time to execute the PCH browser restarts it. As a result I am getting multiple entries in my database because of when the PCH seems to be choosing its restart. It also seems like if it has to restart it too many times it throws an error when infact the script just takes a long time to run. ini_get('max_execution_time') returns a value of 3600, and set time seems to have no effect. Can anyone shed some light on it? cmgrant "Your jambox is now his jambox by way of our actions." cmgrant -[-at-]- gmail -[-dot-]- com |
|||
|
02-16-2009, 08:35 AM
(This post was last modified: 02-16-2009 08:38 AM by journey4712.)
|
|||
|
|||
|
RE: PHP Script restart issue
howabout set_time_limit() ?
There is also ini_set('max_input_time', xxxxxx); iirc opening documents with fopen/etc will add up untill they get to max_input_time, so multiple internet requests could trigger this one. If i remember right there are 3 or 4 things that effect this but i cant find my reference. journey4712 |
|||
|
02-16-2009, 02:47 PM
|
|||
|
|||
|
RE: PHP Script restart issue
I have tried both set_time_limit() and ini_set('max_input_time', xxxxxx); with no luck. It seems to me the initial 3600 (this is 1 hour right?) should be fine. It only gets about 30 seconds of runtime before it gets reset and re-invoked. Is there possibly some other setting that would cause this? There are multiple instances of getting stuff on the net and opening files.
cmgrant "Your jambox is now his jambox by way of our actions." cmgrant -[-at-]- gmail -[-dot-]- com |
|||
|
02-16-2009, 02:54 PM
|
|||
|
|||
|
RE: PHP Script restart issue
Think this was an issue for the Music Album Browser as well... might be worth checking that thread.
http://www.networkedmediatank.com/showth...nd+browser |
|||
|
02-16-2009, 02:56 PM
(This post was last modified: 02-16-2009 02:58 PM by Delphy.)
|
|||
|
|||
|
RE: PHP Script restart issue
Try ini_set('max_execution_time', xxxx);
The /mnt/syb8634/server/php.ini has it set to 30 (hence why the 30 second runtime). So I guess if all else fails you can modify it there and restart the server to see what happens. How are you getting things from the net? file_get_contents() or something else? (On a side note it would be great if we could add in PHP modules or recompile PHP from scratch ... maybe I'll work on that next) My NMT apps / themes |
|||
|
02-16-2009, 06:14 PM
(This post was last modified: 02-16-2009 06:17 PM by cmgrant.)
|
|||
|
|||
RE: PHP Script restart issue
(02-16-2009 02:54 PM)dolph Wrote: Think this was an issue for the Music Album Browser as well... might be worth checking that thread. Thanks I'll check it out. (02-16-2009 02:56 PM)Delphy Wrote: Try ini_set('max_execution_time', xxxx); I have tried Try ini_set('max_execution_time', xxxx); to no avail. Currently I am using wget to pull things down from the net, file_get_contents() to read in those files, and some sqlite database interactions to store information. "Your jambox is now his jambox by way of our actions." cmgrant -[-at-]- gmail -[-dot-]- com |
|||
|
02-16-2009, 06:29 PM
(This post was last modified: 02-16-2009 06:30 PM by Delphy.)
|
|||
|
|||
|
RE: PHP Script restart issue
file_get_contents in normal PHP can handle URL wrappers - the same applies to the one on the PCH. wget is really only handy if you want to grab sub-dirs and so on too.
Try replacing the wget call with just a straight file_get_contents("http://whereever"); - it should be quicker since it doesn't need to wait for a system call as per the wget. Incidentally, are you using the sqlite3 wrappers in PHP? If so, which ones? The normal SQLite3() ones dont work for me. My NMT apps / themes |
|||
|
02-16-2009, 07:05 PM
|
|||
|
|||
RE: PHP Script restart issue
(02-16-2009 06:29 PM)Delphy Wrote: file_get_contents in normal PHP can handle URL wrappers - the same applies to the one on the PCH. wget is really only handy if you want to grab sub-dirs and so on too. Thanks. For the files I am just parsing I will convert over to file_get_contents and just use wget for the images I am downloading. Being a novice in php I don't think I am using the sqlite3 wrappers but here is a list of the command I use Code: sqlite_opencmgrant "Your jambox is now his jambox by way of our actions." cmgrant -[-at-]- gmail -[-dot-]- com |
|||
|
02-16-2009, 07:47 PM
(This post was last modified: 02-16-2009 07:48 PM by Delphy.)
|
|||
|
|||
|
RE: PHP Script restart issue
Thanks - I'll have to check out those sqlite commands - I haven't touched that in a week or so though
![]() You can use file_get_contents() for image files too. ![]() Code: $imageFile = file_get_contents("http://www.networkedmediatank.com/images/logo.gif");My NMT apps / themes |
|||
|
02-18-2009, 06:30 AM
|
|||
|
|||
|
RE: PHP Script restart issue
I have tested file_get_contents with websites and failed miserably. Currently I get two errors back. The first is: php_network_getaddresses: getaddrinfo failed and the second is: failed to open stream: Address family not supported by protocol
Any Idea whats causing this. Something as simple as Code: $filestring = file_get_contents("http://www.google.com");does not even work. I can ping it from the telnet command line though cmgrant "Your jambox is now his jambox by way of our actions." cmgrant -[-at-]- gmail -[-dot-]- com |
|||
|
02-18-2009, 08:13 AM
(This post was last modified: 02-18-2009 08:18 AM by journey4712.)
|
|||
|
|||
|
RE: PHP Script restart issue
The file_get_contents problem, basically as you see the php 4 that is installed in the NMT has a broken getaddrinfo() function. I dont know how to fix it exactly, but there is a way arround it.
The NMT has 2 versions of php on it, php4 and php5. files requested without any special setup are executed with php4 which has the problem. To get your program interpreted with php5, which has a working implementation, you can either a) install the webserver 1.0.0 in the nmt community installer, then you can place files in .www/localhost and access them with http://ip-of-pch:8080/. b) Copy or symlink your files into /opt/sybhttpd/default/ and access them with http://ip-of-pch:8883/. You can only do that from the command line(telnet or editing start_app.sh to symlink a directory on boot(ln -s /share/myprog /opt/sybhttpd/default would make a link from the dir myprog on your harddrive to http://ip-of-pch:8883/myprog/)). journey4712 |
|||
|
02-18-2009, 03:21 PM
|
|||
|
|||
|
RE: PHP Script restart issue
The broken PHP4 getaddrinfo is mostly becuase of the broken hostname setup on the PCH boxes. But journey is correct - you'd need to run another php5 webserver to make it work properly at the moment.
My NMT apps / themes |
|||
|
02-18-2009, 04:48 PM
|
|||
|
|||
|
RE: PHP Script restart issue
Thanks both of you . I guess I'll have to spend some time looking both options.
"Your jambox is now his jambox by way of our actions." cmgrant -[-at-]- gmail -[-dot-]- com |
|||
|
02-18-2009, 05:04 PM
(This post was last modified: 02-18-2009 05:08 PM by Delphy.)
|
|||
|
|||
|
RE: PHP Script restart issue
If you want to be able to use the inbuilt PCH browser/skin (ie gaya) to retrieve files via file_get_contents() then you can use this script to automatically grab a file. It still relys on the php5 webserver, but runs "transparently" to the normal PCH operations.
First, install the webserver (listening on whatever port...8080 or 8082 etc) Next, put this script in the root of your webserver on the PCH (ie /share/.www). Call it getfile.php Code: <?php(You may add error handling if you like... this is quick and dirty though so I left that as an exercise for the reader.) Note that it's hardcoded to put stuff into /share/ but you could change thing if you want. Next, all you have to do is to call this from your normal PCH script like so: Code: file_get_contents("http://127.0.0.1:8082/getfile.php?url=http://www.networkedmediatank.com/images/logo.gif&file=.www/logo.gif");Becuase it's a local URL, the file_get_contents will succeed and call the script located in your Apache/php5 webserver, which will then get the file using the normal file_get_contents(); It's inelegant, yes, but it works and is fairly transparent to your normal script. Note you could even have the getfile.php script *not* automatically save the thing it's grabbing and instead just echo $contents, then have your calling script perform any file save operations etc. (This obviously would be better if you are grabbing HTML contents.) To do this, modify getfile.php to the following: Code: <?phpThen just change your calling script to: Code: $contents = file_get_contents("http://127.0.0.1:8080/getfile.php?url=http://www.networkedmediatank.com/images/logo.gif");Then you can act on $contents just like it was coming from a proper file_get_contents() call. PS replace lt; and gt; with the proper php opening and closing tags
My NMT apps / themes |
|||
|
02-19-2009, 05:06 AM
|
|||
|
|||
|
RE: PHP Script restart issue
Here is a solution the I found that seems to be the easiest for deploying an application for use. It is a simple php5 call wrapped in a shell script.
Code: #!/bin/shand here is how it is invoked from another shell script through a link Code: echo '<TR><TD><A HREF="http://localhost.drives:8883/HARD_DISK/Video/DMJ/execute_php5.cgi?/opt/sybhttpd/localhost.drives/HARD_DISK/Video/DMJ/add_db.php dbname='$database' path='$scanpath'">'"$scanpath"Inside the real php script make sure to trim all the _GET parameters cmgrant "Your jambox is now his jambox by way of our actions." cmgrant -[-at-]- gmail -[-dot-]- com |
|||
|
« Next Oldest | Next Newest »
|

Twitter
Facebook
NMT Wiki
Search
Member List
Help
A-400 [13 May 2013]




![[+]](images/collapse_collapsed.gif)


