PHP Coding
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Codewalkers ForumsPHP RelatedPHP Coding

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Codewalkers Forums Sponsor:
Be the architects of evolution and help create the mobile internet future. It’s your move---enter to win here!
  #1  
Old September 25th, 2002, 01:31 PM
notepad notepad is offline
Codewalkers Loyal (3000 - 3499 posts)
 
Join Date: Apr 2007
Location: Central, IL USA
Posts: 3,214 notepad User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 5
Send a message via AIM to notepad
script execution

i've made a little script, that basically while it is open - never stops executing.. is this very draining on the server if it isn't doing much?

i don't want to tick off my host :eek:

Reply With Quote
  #2  
Old September 25th, 2002, 03:24 PM
Matt Matt is offline
Moderator
Codewalkers Specialist (4000 - 4499 posts)
 
Join Date: Apr 2007
Location: Florida
Posts: 4,158 Matt User rank is Private First Class (20 - 50 Reputation Level)Matt User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 4 h 10 m 20 sec
Reputation Power: 6
RE: script execution

That script would use quite a bit of resources. As an example, the following script will hit the cpu usage to 100%..

php Code:
Original - php Code
  1. <?php
  2. while(1 == 1) {
  3.    $i = 2;
  4. }
  5. ?>


Hopefully, your host is placing some types of limits on the cpu time that each process can take to avoid bad situations...

Reply With Quote
  #3  
Old September 25th, 2002, 04:58 PM
notepad notepad is offline
Codewalkers Loyal (3000 - 3499 posts)
 
Join Date: Apr 2007
Location: Central, IL USA
Posts: 3,214 notepad User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 5
Send a message via AIM to notepad
RE: script execution

well see they are running php is safe mode, so the longest i could normally get a script to execute is 30 seconds.. but then after that 30 seconds is up i got it triggered to refresh itself so it goes another 30 seconds, and it continues until i close the window.

you think this is a bad idea?

Reply With Quote
  #4  
Old September 25th, 2002, 05:26 PM
Matt Matt is offline
Moderator
Codewalkers Specialist (4000 - 4499 posts)
 
Join Date: Apr 2007
Location: Florida
Posts: 4,158 Matt User rank is Private First Class (20 - 50 Reputation Level)Matt User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 4 h 10 m 20 sec
Reputation Power: 6
RE: script execution

Well, it all depends if they are limiting cpu usage on a per process basis. If they are, it doesn't matter. If they aren't, they should let you know there is a problem....that is if they are even paying attention, which I hope they would be....

What are you up to anyway?

Reply With Quote
  #5  
Old September 25th, 2002, 05:42 PM
notepad notepad is offline
Codewalkers Loyal (3000 - 3499 posts)
 
Join Date: Apr 2007
Location: Central, IL USA
Posts: 3,214 notepad User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 5
Send a message via AIM to notepad
RE: script execution

well our intranet here where i work has a strong firewall, and they don't allow us to download any chat software. firewall blocks applets too. so i'm making a minichat to run in a browser with as less refreshing as possible.. (because i find refreshing pages extremely annoying)

my script, runs in an infinite loop to check for new data in a txt file, then sleep for 1 second and check again, if there is no new data it flushes out white space, if there IS new data then it flushes the message. after the 30 or so seconds of execution time is used up, the page then reads the metatag which refreshes the page in 1 second to start the loop again.

it runs beautifully with the exception of a dead page every now and then so i certainly hope it's not a problem. if they are limiting cpu usage on a per process basis what does that mean exactly? will my script just run slower?

i'd be more than happy to give you a copy if you want to test anything. when i get home that is.

Reply With Quote
  #6  
Old September 25th, 2002, 06:44 PM
sarah's Avatar
sarah sarah is offline
Contributing User
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Auckland, New Zealand
Posts: 127 sarah User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 5 m 32 sec
Reputation Power: 2
Send a message via ICQ to sarah Send a message via AIM to sarah Send a message via Google Talk to sarah
RE: script execution

I'd love to see what you have written. I want to put a chat on my website so my visitors can chat with me only using an "visitor" account I will set up for that purpose. ICQ offer an applet but they are all pretty unconfigurable so I'm looking for something more flexible.

Reply With Quote
  #7  
Old September 25th, 2002, 07:08 PM
notepad notepad is offline
Codewalkers Loyal (3000 - 3499 posts)
 
Join Date: Apr 2007
Location: Central, IL USA
Posts: 3,214 notepad User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 5
Send a message via AIM to notepad
RE: script execution

if you think about it, the method i am using could be re-used to really solve most of the problems associated with client-side vs server-side. my script is more or less keeping a persistant connection between the server and the browser, and the browser doesn't need to be refreshed in order to receive new content.

i still have a few updates left to do and i need to find out whether or not this is in fact draining the cpu time. if not, who knows, maybe Matt will consider a browser-based instant messaging system for all us codewalkers

i don't have the code in front of me now sarah, but if you drop me an e-mail i'll send some samples to you.

Reply With Quote
  #8  
Old September 27th, 2002, 12:58 AM
zombie zombie is offline
Codewalkers Intermediate (1500 - 1999 posts)
 
Join Date: Apr 2007
Location: serbia
Posts: 1,876 zombie User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 3
RE: script execution

i wouldn't go that far...

anyway, i so even better php/js chat system. i think it is used in phpGroupWare.

to be short, it goes like this: page is divided in tree (two or more) frames. in the main frame (the biggest) messages are shown.

in a bottom frame, there is a text field (for u to enter a msg) and a submit btn.

and a third frame is invisible! it is that frame that is refreshed every X seconds (as you like) and whenever there are new messages on the server, it contains a simple javascript that adds that msgs to the main frame!

now, that (imho) is a very elegant solution that simulates client/server app!

Reply With Quote
  #9  
Old September 27th, 2002, 02:46 PM
notepad notepad is offline
Codewalkers Loyal (3000 - 3499 posts)
 
Join Date: Apr 2007
Location: Central, IL USA
Posts: 3,214 notepad User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 5
Send a message via AIM to notepad
RE: script execution

however you'd get a longer delay.. and sometimes (for who knows why) refreshing pages go dead, so if you can't see a dead invisible page to manually refresh then what do you do?.

Reply With Quote
  #10  
Old September 27th, 2002, 08:48 PM
zombie zombie is offline
Codewalkers Intermediate (1500 - 1999 posts)
 
Join Date: Apr 2007
Location: serbia
Posts: 1,876 zombie User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 3
RE: script execution

u could refresh that invisible frame from a main or bottom frame. just set a interval or timer (i always get those 2 mixed) in js and it can never go ded.

or, if u want to be shure, make a button in a bottom frame that refreshes the invisible frame.

or, just look at phpGW and see that it works great...

Reply With Quote
  #11  
Old September 27th, 2002, 09:33 PM
notepad notepad is offline
Codewalkers Loyal (3000 - 3499 posts)
 
Join Date: Apr 2007
Location: Central, IL USA
Posts: 3,214 notepad User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 5
Send a message via AIM to notepad
RE: script execution

ahh js refresh i'll have to use that ty and Matt i've found out that my cpu is limited to 10% so i've got nothing to worry about yah? is that gonna lag the rest of my site then when the script is running?

Reply With Quote
  #12  
Old September 30th, 2002, 05:02 PM
notepad notepad is offline
Codewalkers Loyal (3000 - 3499 posts)
 
Join Date: Apr 2007
Location: Central, IL USA
Posts: 3,214 notepad User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 5
Send a message via AIM to notepad
RE: script execution

m'kay, even with the js refresh i still get dead pages occasionally.. dunno. oh well

Reply With Quote
  #13  
Old October 1st, 2002, 03:30 AM
zombie zombie is offline
Codewalkers Intermediate (1500 - 1999 posts)
 
Join Date: Apr 2007
Location: serbia
Posts: 1,876 zombie User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 3
RE: script execution

how did u do a js refresh thingy?

it is important that u do it from a diferent frame than the frame u use for mesages...

and to use that func that calls a function every X (30) seconds...

btw, i can't check. i can't catch u to be in a room...

Reply With Quote
  #14  
Old October 1st, 2002, 06:25 AM
notepad notepad is offline
Codewalkers Loyal (3000 - 3499 posts)
 
Join Date: Apr 2007
Location: Central, IL USA
Posts: 3,214 notepad User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 5
Send a message via AIM to notepad
RE: script execution

i'm just using the following..

<NOSCRIPT>
<meta http-equiv="refresh" content="1">
</NOSCRIPT>
<body onLoad="window.setTimeout(location.href='top.php',1000)">

since the page doesn't actually load fully for about a minute, until then it's just flushing out info and then reads the onload tag to restart the flushing..

Reply With Quote
  #15  
Old October 2nd, 2002, 12:49 AM
zombie zombie is offline
Codewalkers Intermediate (1500 - 1999 posts)
 
Join Date: Apr 2007
Location: serbia
Posts: 1,876 zombie User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 3
RE: script execution

and it doesn't work all the time?

why don't u try "my way".

onLoad can't be trusted...

Reply With Quote
Reply

Viewing: Codewalkers ForumsPHP RelatedPHP Coding > script execution


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump