On Aug 26, 2011, at 9:51 AM, Sebastian E. Ovide wrote:

> what about "something" like this ?
> 
> #!/bin/bash
> if test "/path/to/VERSION" -nt "/path/to/VERSION.track"
> then
>  # touch VERSION.track
>  # restart apache
> else
>  nothing
> fi
> 
> 
> and run it in cron once every 5 minutes or so ....

I think that's basically the way to do it (and it should work fine on OS X, 
too). One caveat, though. Is web2py ready to start as soon as VERSION is 
written? If there's any housekeeping (unpacking or the like) that needs to 
happen first, the restart might be premature.

Also, might it be useful to have web2py touch a timestamp file when it starts 
(well, not if it's under GAE, but otherwise)? That would give us a hook for an 
uptime function, as well as supporting this functionality.

As with my caveat, it has a bit of a race problem, since the timestamp file 
gets touched some finite time after the restart event. Maybe something like:

if test... ; then
    sleep 1
    if test...; then
        now do your stuff
    fi
fi

> 
> On Fri, Aug 26, 2011 at 5:43 PM, Massimo Di Pierro 
> <[email protected]> wrote:
> How would you write a cron job that automatically restarts apache when
> the file web2py/VERSION is touched/modified and works on both ubuntu
> and fedora?


Reply via email to