Running PostgreSQL with Supervisord

后端 未结 3 998
無奈伤痛
無奈伤痛 2021-02-09 23:06

I want to run PostgreSQL 9.1 using Supervisor on Ubuntu 10.04. At the moment, I manually start PostgreSQL using the init script:

/etc/init.d/postgresql start
         


        
3条回答
  •  南旧
    南旧 (楼主)
    2021-02-10 00:03

    I am trying to make both tomcat and postgres run under supervisor, and found some hints here : https://serverfault.com/questions/425132/controlling-tomcat-with-supervisor

    Here is my modified run_postgresql.sh, using bash :

    #!/bin/bash
    
    # This script is run by Supervisor to start PostgreSQL 9.1 in foreground mode
    
    function shutdown()
    {
        echo "Shutting down PostgreSQL"
        pkill postgres
    }
    
    if [ -d /var/run/postgresql ]; then
        chmod 2775 /var/run/postgresql
    else
        install -d -m 2775 -o postgres -g postgres /var/run/postgresql
    fi
    
    # Allow any signal which would kill a process to stop PostgreSQL
    trap shutdown HUP INT QUIT ABRT KILL ALRM TERM TSTP
    
    exec sudo -u postgres /usr/lib/postgresql/9.1/bin/postgres -D /var/lib/postgresql/9.1/main --config-file=/etc/postgresql/9.1/main/postgresql.conf
    

    With this script postgresql stops correctly after supervisorctl stop postgres.

提交回复
热议问题