Re: [PHP] Re: skinning a cat

2008-09-02 Thread Robert Cummings
On Tue, 2008-09-02 at 18:02 +0200, Per Jessen wrote:
> Robert Cummings wrote:
> 
> > You originally said it was overkill to use my lock class and then went
> > on to show your shell script doing similar. To which I then responded
> > try running the shell script in windows. To which you've now suggested
> > installing cygwin. 
> 
> Well, no I haven't, but feel free to think so.  

Ok, maybe you didn't explicitly suggest installing cygwin but you did
write:

"And of course, there's also Cygwin."

As a method of running the shell script you provided. That struck me as
a suggestion... but I won't quibble. Obviously you meant someone could
use cygwin without installing it.

> > Thus you have suggested a shell script and cygwin to accomplish what a
> > simple lock class easily achieves in both linux and windows.  
> 
> OK, if you want to debate this - you take a relatively complex solution
> which is intended for 1% of your customers, and apply it to the other
> 99% which could have done with a much simpler solution. That's more
> overkill, IMHO.

No, I take a single solution that works for 99% of my clients and just
so happens to work for the other 1% because the solution is homogenous.
Additionally the solution is re-usable and can be applied at ANY point
within the PHP code. Your solution is required to wrap the PHP script
invocation and thus is not as versatile. Additionally my solution is
hardly complex. Ooooh... a class wrapper around mkdir() that's tuff to
grok. Similarly adding features to the class is simplistic and instantly
available to all applications that want to use locks and not just
applications wanting to be launched from a shell script that manages the
locks. I guess you also have problems with using PHP classes that pull
in directory listings, perform file uploads/downloads, image
manipulations, etc. All these can be done with the shell, by extension
of your argument they appear to have no place in PHP code.

Moving along... why the heck would anyone want to punt logic to the
shell that could easily be incorporated into the application. You almost
certainly give up control and flexibility in such cases.

Cheers,
Rob.
-- 
http://www.interjinn.com
Application and Templating Framework for PHP


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Re: skinning a cat

2008-09-02 Thread Per Jessen
Robert Cummings wrote:

> You originally said it was overkill to use my lock class and then went
> on to show your shell script doing similar. To which I then responded
> try running the shell script in windows. To which you've now suggested
> installing cygwin. 

Well, no I haven't, but feel free to think so.  

> Thus you have suggested a shell script and cygwin to accomplish what a
> simple lock class easily achieves in both linux and windows.  

OK, if you want to debate this - you take a relatively complex solution
which is intended for 1% of your customers, and apply it to the other
99% which could have done with a much simpler solution. That's more
overkill, IMHO. 


/Per Jessen, Zürich


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Re: skinning a cat

2008-09-02 Thread Robert Cummings
On Tue, 2008-09-02 at 16:23 +0200, Per Jessen wrote:
> Robert Cummings wrote:
> 
> > On Tue, 2008-09-02 at 07:52 +0200, Per Jessen wrote:
> >> Lupus Michaelis wrote:
> >> 
> >> > Robert Cummings a écrit :
> >> > 
> >> >> Try running that on windows.
> >> > 
> >> >No problem
> >> > 
> >> > 
> >> 
> >> And of course, there's also Cygwin.
> > 
> > *lol* And I quote:
> > 
> > Per Jessen said:
> > "I'm probably old fashioned, but to me all that stuff is way
> >  overkill."
> > 
> > And now your suggesting installing cygwin to accomplish something so
> > easily accomplished in PHP.
> > 
> > Yeesh.
> 
> Rob, I've never suggested anything like that.  But if you were to ask me
> how to get a fairly decent Unix-like environment on a Windows platform,
> yes, I would suggest using Cygwin.

You originally said it was overkill to use my lock class and then went
on to show your shell script doing similar. To which I then responded
try running the shell script in windows. To which you've now suggested
installing cygwin. Thus you have suggested a shell script and cygwin to
accomplish what a simple lock class easily achieves in both linux and
windows. It all goes back to that original argument you brought up where
you said the lock class was overkill. I haven't even commented on the
complexity added by introducing a second technology (And third now that
cygwin is on the table). I'm sure this is a prime example for the
application of Occam's Razor.

Cheers,
Rob.
-- 
http://www.interjinn.com
Application and Templating Framework for PHP


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Re: skinning a cat

2008-09-02 Thread Per Jessen
Robert Cummings wrote:

> On Tue, 2008-09-02 at 07:52 +0200, Per Jessen wrote:
>> Lupus Michaelis wrote:
>> 
>> > Robert Cummings a écrit :
>> > 
>> >> Try running that on windows.
>> > 
>> >No problem
>> > 
>> > 
>> 
>> And of course, there's also Cygwin.
> 
> *lol* And I quote:
> 
> Per Jessen said:
> "I'm probably old fashioned, but to me all that stuff is way
>  overkill."
> 
> And now your suggesting installing cygwin to accomplish something so
> easily accomplished in PHP.
> 
> Yeesh.

Rob, I've never suggested anything like that.  But if you were to ask me
how to get a fairly decent Unix-like environment on a Windows platform,
yes, I would suggest using Cygwin.


/Per Jessen, Zürich


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Re: skinning a cat

2008-09-02 Thread Robert Cummings
On Tue, 2008-09-02 at 07:52 +0200, Per Jessen wrote:
> Lupus Michaelis wrote:
> 
> > Robert Cummings a écrit :
> > 
> >> Try running that on windows.
> > 
> >No problem
> > 
> > 
> 
> And of course, there's also Cygwin.

*lol* And I quote:

Per Jessen said:
"I'm probably old fashioned, but to me all that stuff is way
 overkill."

And now your suggesting installing cygwin to accomplish something so
easily accomplished in PHP.

Yeesh.

Cheers,
Rob.
-- 
http://www.interjinn.com
Application and Templating Framework for PHP


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Re: skinning a cat

2008-09-01 Thread Per Jessen
Lupus Michaelis wrote:

> Robert Cummings a écrit :
> 
>> Try running that on windows.
> 
>No problem
> 
> 

And of course, there's also Cygwin. 


/Per Jessen, Zürich


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Re: skinning a cat

2008-09-01 Thread Lupus Michaelis

Robert Cummings a écrit :


Try running that on windows.


  No problem 



--
Mickaël Wolff aka Lupus Michaelis
http://lupusmic.org

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Re: skinning a cat (was: Individual bulk e-mails - performance question)

2008-09-01 Thread Robert Cummings
On Mon, 2008-09-01 at 20:22 +0200, Per Jessen wrote:
> Robert Cummings wrote:
> 
> >> I'm probably old fashioned, but to me all that stuff is way overkill.
> >>  I also tend to think that synchronizing scripts is a job for the
> >> shell, not PHP.
> >> 
> >> lockfile=/var/lock//file
> >> # clear out a lock older than 60mins
> >> find $lockfile -cmin +60 | xargs rm
> >> test ! -f $lockfile && (
> >> touch $lockfile
> >> 
> >> rm -f $lockfile
> >> )
> > 
> > Try running that on windows.
> 
> Why? - we don't use Windows.

I get requests from time to time to do windows work. My scripts just
happen to work in windows or linux. I guess that's because I don't punt
to shell scripts what is easily implemented in PHP ;)

99% of what I do is linux based. But knowing what to do for the other 1%
is pure gold to my clients.

Cheers,
Rob.
-- 
http://www.interjinn.com
Application and Templating Framework for PHP


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Re: skinning a cat

2008-09-01 Thread Per Jessen
Robert Cummings wrote:

> The return value of creating the directory is either true for it
> having been made or false for it having not been made. Therein lies
> the atomicity. The OS will not return success if it was not made and
> will not return failure if it was made.

Ah, interesting.  Thanks.


/Per Jessen, Zürich


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Re: skinning a cat (was: Individual bulk e-mails - performance question)

2008-09-01 Thread Per Jessen
Robert Cummings wrote:

>> I'm probably old fashioned, but to me all that stuff is way overkill.
>>  I also tend to think that synchronizing scripts is a job for the
>> shell, not PHP.
>> 
>> lockfile=/var/lock//file
>> # clear out a lock older than 60mins
>> find $lockfile -cmin +60 | xargs rm
>> test ! -f $lockfile && (
>> touch $lockfile
>> 
>> rm -f $lockfile
>> )
> 
> Try running that on windows.

Why? - we don't use Windows. 


/Per Jessen, Zürich


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Re: skinning a cat

2008-09-01 Thread Robert Cummings
On Mon, 2008-09-01 at 14:51 +0200, Per Jessen wrote:
> Jochem Maas wrote:
> 
> > Per Jessen schreef:
> >> Jochem Maas wrote:
> >> 
>  lockfile=/var/lock//file
>  # clear out a lock older than 60mins
>  find $lockfile -cmin +60 | xargs rm
>  test ! -f $lockfile && (
>  touch $lockfile
>  
>  rm -f $lockfile
>  )
> >>> wouldn't creating a dir be better here? (with regard to atomicity)
> >>>
> >> 
> >> I haven't thought it through, but I don't think it would change
> >> anything.
> > 
> > directory creation is garanteed to be atomic, even across NFS, or
> > so Rob said. 
> 
> Maybe so, but to avoid a race-condition, you need the test+touch
> sequence to be atomic.

The return value of creating the directory is either true for it having
been made or false for it having not been made. Therein lies the
atomicity. The OS will not return success if it was not made and will
not return failure if it was made.

Cheers,
Rob.
-- 
http://www.interjinn.com
Application and Templating Framework for PHP


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Re: skinning a cat (was: Individual bulk e-mails - performance question)

2008-09-01 Thread Robert Cummings
On Mon, 2008-09-01 at 09:44 +0200, Per Jessen wrote:
> Robert Cummings wrote:
> 
> >> >> #!/bin/sh
> >> >> while true
> >> >> do
> >> >> 
> >> >> sleep 300
> >> >> done
> >> > 
> >> > I accomplish the same with cron scripts by using locks with expiry.
> >> 
> >> got an example? my cat skinning skills need to be improved, the cat
> >> won't like it but screw the cat, right?
> > 
> [snip code]
> > I implemented my own lock class which uses directory creation and the
> > return value to determine if the lock was successful. Unlike file
> > creation (or so I read several years ago) directory creation is atomic
> > and works across NFS. As an added benefit, I'm able to store lock
> > related data into the lock directory as files.
> 
> I'm probably old fashioned, but to me all that stuff is way overkill.  I
> also tend to think that synchronizing scripts is a job for the shell,
> not PHP. 
> 
> lockfile=/var/lock//file
> # clear out a lock older than 60mins
> find $lockfile -cmin +60 | xargs rm
> test ! -f $lockfile && (
> touch $lockfile
> 
> rm -f $lockfile
> )

Try running that on windows.

Cheers,
Rob.
-- 
http://www.interjinn.com
Application and Templating Framework for PHP


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Re: skinning a cat

2008-09-01 Thread Per Jessen
Jochem Maas wrote:

> Per Jessen schreef:
>> Jochem Maas wrote:
>> 
 lockfile=/var/lock//file
 # clear out a lock older than 60mins
 find $lockfile -cmin +60 | xargs rm
 test ! -f $lockfile && (
 touch $lockfile
 
 rm -f $lockfile
 )
>>> wouldn't creating a dir be better here? (with regard to atomicity)
>>>
>> 
>> I haven't thought it through, but I don't think it would change
>> anything.
> 
> directory creation is garanteed to be atomic, even across NFS, or
> so Rob said. 

Maybe so, but to avoid a race-condition, you need the test+touch
sequence to be atomic. 



/Per Jessen, Zürich


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Re: skinning a cat

2008-09-01 Thread Jochem Maas

Per Jessen schreef:

Jochem Maas wrote:


lockfile=/var/lock//file
# clear out a lock older than 60mins
find $lockfile -cmin +60 | xargs rm
test ! -f $lockfile && (
touch $lockfile

rm -f $lockfile
)

wouldn't creating a dir be better here? (with regard to atomicity)



I haven't thought it through, but I don't think it would change
anything. 


directory creation is garanteed to be atomic, even across NFS, or
so Rob said. additionally his idea of being able to dump lock-process
related data in said directory is quite nifty.




/Per Jessen, Zürich





--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Re: skinning a cat

2008-09-01 Thread Jochem Maas

Colin Guthrie schreef:

Jochem Maas wrote:
either way, I've just learn't something new as far as shellscripting 
goes :-)

apart from the xargs command ... that still does my head in (don't worry
I'll look it up ... for the umpteenth time).


find $lockfile -cmin +60 | xargs rm


FWIW, it's nicer to do:
$ find $lockfine -cmin +60 -exec rm {} \;


This method handles files with spaces in them, where are the xargs 
method does not (not that it matters in this case).


righto, good to know. -exec option of a find is one I still have to
look up every time I use it (although I think I guess the syntax correctly ... 
once)


HTHs

Col




--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Re: skinning a cat

2008-09-01 Thread Per Jessen
Jochem Maas wrote:

>> lockfile=/var/lock//file
>> # clear out a lock older than 60mins
>> find $lockfile -cmin +60 | xargs rm
>> test ! -f $lockfile && (
>> touch $lockfile
>> 
>> rm -f $lockfile
>> )
> 
> wouldn't creating a dir be better here? (with regard to atomicity)
> 

I haven't thought it through, but I don't think it would change
anything. 


/Per Jessen, Zürich


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Re: skinning a cat

2008-09-01 Thread Per Jessen
Colin Guthrie wrote:

> Jochem Maas wrote:
>> either way, I've just learn't something new as far as shellscripting
>> goes :-)
>> apart from the xargs command ... that still does my head in (don't
>> worry I'll look it up ... for the umpteenth time).
>>>
>>> find $lockfile -cmin +60 | xargs rm
> 
> FWIW, it's nicer to do:
> $ find $lockfine -cmin +60 -exec rm {} \;
> 
> 
> This method handles files with spaces in them, where are the xargs
> method does not (not that it matters in this case).

That could also be taken care of by:

find $lockfile -cmin +60 -print0 | xargs -0 rm

IMO, the syntax of the -exec argument is too cumbersome. 


/Per Jessen, Zürich


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Re: skinning a cat

2008-09-01 Thread Colin Guthrie

Jochem Maas wrote:
either way, I've just learn't something new as far as shellscripting 
goes :-)

apart from the xargs command ... that still does my head in (don't worry
I'll look it up ... for the umpteenth time).


find $lockfile -cmin +60 | xargs rm


FWIW, it's nicer to do:
$ find $lockfine -cmin +60 -exec rm {} \;


This method handles files with spaces in them, where are the xargs 
method does not (not that it matters in this case).


HTHs

Col

--

Colin Guthrie
gmane(at)colin.guthr.ie
http://colin.guthr.ie/

Day Job:
  Tribalogic Limited [http://www.tribalogic.net/]
Open Source:
  Mandriva Linux Contributor [http://www.mandriva.com/]
  PulseAudio Hacker [http://www.pulseaudio.org/]
  Trac Hacker [http://trac.edgewall.org/]


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Re: skinning a cat

2008-09-01 Thread Jochem Maas

Per Jessen schreef:

Robert Cummings wrote:


#!/bin/sh
while true
do

sleep 300
done

I accomplish the same with cron scripts by using locks with expiry.

got an example? my cat skinning skills need to be improved, the cat
won't like it but screw the cat, right?

[snip code]

I implemented my own lock class which uses directory creation and the
return value to determine if the lock was successful. Unlike file
creation (or so I read several years ago) directory creation is atomic
and works across NFS. As an added benefit, I'm able to store lock
related data into the lock directory as files.


I'm probably old fashioned, but to me all that stuff is way overkill.  I
also tend to think that synchronizing scripts is a job for the shell,
not PHP. 


either way, I've just learn't something new as far as shellscripting goes :-)
apart from the xargs command ... that still does my head in (don't worry
I'll look it up ... for the umpteenth time).


lockfile=/var/lock//file
# clear out a lock older than 60mins
find $lockfile -cmin +60 | xargs rm
test ! -f $lockfile && (
touch $lockfile

rm -f $lockfile
)


wouldn't creating a dir be better here? (with regard to atomicity)





/Per Jessen, Zürich





--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Re: skinning a cat (was: Individual bulk e-mails - performance question)

2008-09-01 Thread Per Jessen
Robert Cummings wrote:

>> >> #!/bin/sh
>> >> while true
>> >> do
>> >> 
>> >> sleep 300
>> >> done
>> > 
>> > I accomplish the same with cron scripts by using locks with expiry.
>> 
>> got an example? my cat skinning skills need to be improved, the cat
>> won't like it but screw the cat, right?
> 
[snip code]
> I implemented my own lock class which uses directory creation and the
> return value to determine if the lock was successful. Unlike file
> creation (or so I read several years ago) directory creation is atomic
> and works across NFS. As an added benefit, I'm able to store lock
> related data into the lock directory as files.

I'm probably old fashioned, but to me all that stuff is way overkill.  I
also tend to think that synchronizing scripts is a job for the shell,
not PHP. 

lockfile=/var/lock//file
# clear out a lock older than 60mins
find $lockfile -cmin +60 | xargs rm
test ! -f $lockfile && (
touch $lockfile

rm -f $lockfile
)


/Per Jessen, Zürich


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php