Init.d script for Postgresql 9.6 on ubuntu 14 is not working after reboot

December 1, 2017 912 views
PostgreSQL Ubuntu
BMiro003
By:
BMiro003

I have droplet running Ubuntu 14.04 with preconfigured postgresql, rails and nginx.
I am running apt-get upgrade when necessary and all worked fine until today when I saw in console that reboot is required.
After reboot I found out that my init.d scripts for postgresql are not runing. They show OK for start, or stop but service actually is not started or stoped.
I have to manually execute postgres what is not suitable. Could you help my why this happened and how to update init.d script for postgres 9.6 ?
thanks

2 comments
  • The version of Postgresql shipped on the Rails One-Click application is the default version from the Ubuntu repositories. No custom init script is used. By default Ubuntu 14.04 ships Postgresql 9.3. Have you installed installed a new version from a third-party repository? Can you share the init script and any relevant logs?

  • I upgraded postgres from default repo, didnt use any other. Later I found that I had installed already postgres 10, so when I upgraded my pgcluster to 10 it started to work.
    But later, I forgot to remove old postgres install files and after their upgrade, it is not working again. I did test like 10 minutes ago, service postgresql stop/start did nothing, I have to run it manually with pg_ctl command

    this is my init script

    #!/bin/sh
    set -e
    
    ### BEGIN INIT INFO
    # Provides:             postgresql
    # Required-Start:       $local_fs $remote_fs $network $time
    # Required-Stop:        $local_fs $remote_fs $network $time
    # Should-Start:         $syslog
    # Should-Stop:          $syslog
    # Default-Start:        2 3 4 5
    # Default-Stop:         0 1 6
    # Short-Description:    PostgreSQL RDBMS server
    ### END INIT INFO
    
    # Setting environment variables for the postmaster here does not work; please
    # set them in /etc/postgresql/<version>/<cluster>/environment instead.
    
    [ -r /usr/share/postgresql-common/init.d-functions ] || exit 0
    
    . /usr/share/postgresql-common/init.d-functions
    
    # versions can be specified explicitly
    if [ -n "$2" ]; then
        versions="$2 $3 $4 $5 $6 $7 $8 $9"
    else
        get_versions
    fi
    
    case "$1" in
        start|stop|restart|reload)
            if [ "$1" = "start" ]; then
                create_socket_directory
            fi
            if [ -z "`pg_lsclusters -h`" ]; then
                log_warning_msg 'No PostgreSQL clusters exist; see "man pg_createcluster"'
                exit 0
            fi
            for v in $versions; do
                $1 $v || EXIT=$?
            done
            exit ${EXIT:-0}
            ;;
        status)
            LS=`pg_lsclusters -h`
            # no clusters -> unknown status
            [ -n "$LS" ] || exit 4
            echo "$LS" | awk 'BEGIN {rc=0} {if (match($4, "down")) rc=3; printf ("%s/%s (port %s): %s\n", $1, $2, $3, $4)}; END {exit rc}'
            ;;
        force-reload)
            for v in $versions; do
                reload $v
            done
            ;;
        *)
            echo "Usage: $0 {start|stop|restart|reload|force-reload|status} [version ..]"
            exit 1
            ;;
    esac
    
    exit 0
    
    
1 Answer
Have another answer? Share your knowledge.