The closer you can do it to the process itself, the better. The :exit
event handler is a good bet. Doing it in both places can't hurt,
though.

- Jamis

On 8/2/07, goodieboy <[EMAIL PROTECTED]> wrote:
>
> Ha ha ha! That's funny. To be honest, I mumbled to my wife the other
> night... "don't ever let me do another PHP project", I'm not kidding.
>
> So, I guess my question is should I delete the pid file in an exit
> event handler within capistrano, delete when my monitoring/pooling
> script knows that the process doesn't exist anymore, or... both?
>
> Thanks!
>
> On Aug 2, 1:29 pm, "Jamis Buck" <[EMAIL PROTECTED]> wrote:
> > I thank all that is holy, several times every day, that I have never
> > needed to have any experience with PHP. :) Thus, I have no idea how
> > you might do that in PHP. In Ruby, there is Process.wait (and
> > friends). I imagine PHP would have something similar.
> >
> > - Jamis
> >
> > On 8/2/07, goodieboy <[EMAIL PROTECTED]> wrote:
> >
> >
> >
> > > Ahh, cool. I'm just shelling out to cap; using PHP5 :)
> >
> > > So how do I know when the pid finishes? Would I just shell out to "ps -
> > > p $$" ?
> >
> > > Thanks Jamis!
> > > Matt
> >
> > > On Aug 2, 1:15 pm, "Jamis Buck" <[EMAIL PROTECTED]> wrote:
> > > > Are you embedding Capistrano in your app, or are you shelling out to
> > > > the 'cap' command?
> >
> > > > If the former, then it should be easy to know when the command
> > > > finishes, since the task will return. :) If the latter, you could do
> > > > something like this in your capfile:
> >
> > > >   task :write_pid_file do
> > > >     File.open("/tmp/capistrano.pid", "w") { |f| f.write($$) }
> > > >   end
> >
> > > >   on :start, :write_pid
> >
> > > > Then, you fire off the cap command, wait for "/tmp/capistrano.pid" to
> > > > appear, and read it, and then wait for that pid to finish.
> >
> > > > Do either of those fit your usage scenario?
> >
> > > > - Jamis
> >
> > > > On 8/2/07, goodieboy <[EMAIL PROTECTED]> wrote:
> >
> > > > > Ahh sorry, should describe this better... I said remote, but meant
> > > > > "ajax"
> >
> > > > > I've got a web app, that triggers a local capistrano task. I've
> > > > > cusomized the capistrano logger, so that in addition to writing to the
> > > > > console, I'm writing to a tmp file. As soon as the web app triggers
> > > > > the task, it starts firing off ajax requests to another script which
> > > > > then returns the content of the tmp log file. That way I get live
> > > > > feedback right in the browser. It actually works quite well!
> > > > > Currently, I have an exit event that writes 'COMPLETE' to the log
> > > > > file, when the ajax polling request sees that at the end of the file,
> > > > > it clears the file and then the polling stops. The problem is,
> > > > > sometimes it gets off, not sure why but things happen. So I'm just
> > > > > experimenting, trying to find the most reliable way to find out when
> > > > > the task is done, or has completely failed.
> >
> > > > > Matt
> >
> > > > > On Aug 2, 12:58 pm, "Jamis Buck" <[EMAIL PROTECTED]> wrote:
> > > > > > I'm confused...how is the Capistrano logger writing to a remote 
> > > > > > server?
> >
> > > > > > - Jamis
> >
> > > > > > On 8/2/07, goodieboy <[EMAIL PROTECTED]> wrote:
> >
> > > > > > > I see. I'm using a remote script to poll a temp log file created 
> > > > > > > by
> > > > > > > the Capistrano logger and need a reliable way to know when it has
> > > > > > > stopped the task/command. Do you think if I just create even 
> > > > > > > handlers
> > > > > > > that create and delete a file, that would work just as well? So 
> > > > > > > if the
> > > > > > > file is there the command is still running, if it's not there then
> > > > > > > there isn't anything running? I'm worried about the case where a
> > > > > > > Capistrano task (or parent process) may die, and not call the exit
> > > > > > > event handler. Do you have any advice? :)
> >
> > > > > > > Matt
> >
> > > > > > > On Aug 2, 11:05 am, "Jamis Buck" <[EMAIL PROTECTED]> wrote:
> > > > > > > > Do you mean, the process id of Capistrano itself, or the 
> > > > > > > > process id of
> > > > > > > > the processes that Capistrano executes remotely?
> >
> > > > > > > > In the first case, the Ruby variable $$ will give you 
> > > > > > > > Capistrano's pid
> > > > > > > > on the machine you are running Capistrano, In the latter case, 
> > > > > > > > no,
> > > > > > > > Capistrano doesn't provide a means to grab the pid of an 
> > > > > > > > arbitrary
> > > > > > > > process. Most programs that are meant to be run as a daemon 
> > > > > > > > support an
> > > > > > > > option for writing the pid to a file, though.
> >
> > > > > > > > - Jamis
> >
> > > > > > > > On 8/2/07, goodieboy <[EMAIL PROTECTED]> wrote:
> >
> > > > > > > > > Hi,
> >
> > > > > > > > > I'm wondering if there is a way to get the current Capistrano 
> > > > > > > > > process
> > > > > > > > > id? I'm thinking about creating event handlers to create a 
> > > > > > > > > pid file
> > > > > > > > > before any task, and remove the file on exit. It'd be nice to 
> > > > > > > > > actually
> > > > > > > > > put the pid in there though. Is there a way to do this?
> >
> > > > > > > > > Thanks
> > > > > > > > > Matt
>
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/capistrano
-~----------~----~----~----~------~----~------~--~---

Reply via email to