Forum OpenACS Q&A: Re: Postgres not starting up after power failure

Collapse
Posted by Jonathan Ellis on
I ran into this problem on my freebsd system, so I created a helper program which I call from the postgres init script:
#!/usr/local/bin/tclsh8.3

set PID_F /usr/local/pgsql/data/postmaster.pid

if [file exists $PID_F] {
    set pid [lindex [split [exec cat $PID_F] \n] 0]
    set exists [string length [exec ps ax | awk "\$1 == $pid {print}"]]

    if !$exists {
        exec rm $PID_F
        exec logger "pg_rmpid: invalid pid; removed $PID_F"
    }
}
Collapse
Posted by Jade Rubick on
Should this be put in the default install script? It seems like a good idea. A server shouldn't stay down if there was a power failure, right?

Do you call this at the beginning of the startup portion of your Postgres startup script?