Forum OpenACS Q&A: Re: DB Connection Error

Collapse
15: Re: DB Connection Error (response to 14)
Posted by danny kim on
It's the first time to install openACS.

1. /etc/init.d/aolserver4
#!/bin/sh
#
# Start the AOLServer HTTP server.
#
# Copyright (C) 2003-2009 Francesco P. Lovergine <mailto:frankie@debian.org>
#

### BEGIN INIT INFO
# Provides:          aolserver4
# Required-Start:    $local_fs $remote_fs $network $syslog
# Required-Stop:    $local_fs $remote_fs $network $syslog
# Default-Start:    2 3 4 5
# Default-Stop:      0 1 6
# Should-Start:      $postgresql
# Should-Stop:      $postgresql
# Short-Description: Starts AOLserver web daemon
# Description:      It starts up the AOLserver http multi-threaded
#                    server
### END INIT INFO

NAME=aolserver4
USER=www-data
GROUP=www-data
ADDRESS=127.0.0.1
HTTP_PORT=80
DAEMON=/usr/sbin/aolserver4-nsd
PIDFILE=/var/run/aolserver4/$NAME.pid
CONF=/etc/aolserver4/aolserver4.tcl
RUN_DAEMON=yes

trap "" 1

[ -x $DAEMON ] || exit 0

. /lib/lsb/init-functions

if [ -x /etc/default/aolserver4 ]; then
    . /etc/default/aolserver4
fi

# /var/run could be on a tmpfs

[ ! -d $RUNDIR ] && mkdir -p -m 755 $RUNDIR

start()
{
    if [ "$RUN_DAEMON" = "yes" ]; then
        log_daemon_msg "Starting web server" "$NAME"
        start-stop-daemon --start --quiet --exec $DAEMON --pidfile $PIDFILE --oknodo -- \
            -u $USER -g $GROUP -b $ADDRESS:$HTTP_PORT -s main -t $CONF >/dev/null
        if [ $? != 0 ]; then
            log_end_msg 1
        exit 1
        else
            log_end_msg 0
        fi
    fi

    for name in /etc/aolserver4/conf.d/*.sh; do
        base=$(basename $name .sh)
        if [ -e /etc/aolserver4/conf.d/$base.tcl ]; then
            AOL_PIDFILE=/var/run/aolserver4/$base.pid
            AOL_ADDRESS=$ADDRESS
            AOL_PORT=$(expr $HTTP_PORT + 1)
            AOL_USER=$USER
            AOL_GROUP=$GROUP
            RUN_DAEMON=yes
            . $name
            if [ "$RUN_DAEMON" = "yes" ]; then
                log_daemon_msg "Starting AOL instance" "$base"
                start-stop-daemon --start --quiet --exec $DAEMON --pidfile $AOL_PIDFILE --oknodo -- \
                    -u $AOL_USER -g $AOL_GROUP -b $AOL_ADDRESS:$AOL_PORT -s $base -t /etc/aolserver4/conf.d/$base.tcl >/dev/null
                if [ $? != 0 ]; then
                    log_end_msg 1
                exit 1
                else
                    log_end_msg 0
                fi
            fi
        fi
    done
}

stop()
{
    for name in /var/run/aolserver4/*.pid; do
        if [ -f $name ]; then
            base=$(basename $name .pid)
            log_daemon_msg "Stopping web server" "$base"
            start-stop-daemon --stop --quiet --pidfile $name --oknodo >/dev/null
            if [ $? != 0 ]; then
                log_end_msg 1
            exit 2
            else
                log_end_msg 0
            fi
        fi
    done
}

case "$1" in
  start)
    start
    ;;

  stop)
    stop
    ;;

  reload|force-reload|restart)
    stop
    sleep 2
    start
    ;;

  *)
    echo "Usage: /etc/init.d/$NAME {start|stop|restart|reload|force-reload}"
    exit 1
    ;;
esac

exit 0


2. openacs.sh

#!/bin/sh
# These variables can be customized to change OpenACS AOLserver settings.
# More changes can be done by modifying the /etc/openacs/config.tcl Tcl script.
#
AOL_USER=www-data
AOL_GROUP=www-data
AOL_ADDRESS=127.0.0.1
AOL_PORT=8000
RUN_DAEMON=yes


3. openacs
#!/bin/sh -e
#
# Start the AOLServer HTTP server.
#

NAME="OpenACS on service1"
SERVICEPATH=/var/lib/aolserver/service1
PATH=$PATH:/bin:/usr/bin:/sbin:/usr/sbin:/usr/local/pgsql/bin
#trap "" 1

. /lib/lsb/init-functions

start () {
혻혻 echo -n "Starting web server: $NAME"
혻혻 echo -e -n "\r"

혻혻 #we need to export the library stuff first
혻혻 export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/pgsql/lib
혻혻 export PATH=$PATH:/usr/local/pgsql/bin

혻혻혻 # give time for Postgres to come up
혻혻혻 sleep 1
혻혻혻 exec /usr/sbin/aolserver4-nsd -it $SERVICEPATH/etc/config.tcl -u service1 -g web &

혻혻혻 # For AOLserver 4 using privileged ports (usually < 1024), add the flag
혻혻 # -b youraddress:yourport
혻혻혻 echo ""
}

stop () {
혻혻혻 echo -n "Stopping web server: $NAME"
혻혻혻 killall aolserver4-nsd
혻혻혻 echo ""
}

case "$1" in
  start)
    start
    ;;
  stop)
    ;;
  restart)
    stop
    sleep 2
    start
    ;;
  *)
    echo "Usage: /etc/init.d/$NAME {start|stop|restart}"
    exit 1
    ;;
esac

#echo -n -e "\c\r\n"
exit 0
# End of script

Thanks

Collapse
16: Re: DB Connection Error (response to 15)
Posted by Héctor Romojaro on
Hi Danny,

I guess you are installing OpenACS using the debian packages (nice!), so the only file you should need to edit is /etc/aolserver4/conf.d/openacs.sh, and all other changes should be done vía debconf.

If you are sure that the postgresql installation is correct, my advice is to purge the openacs package, drop the database, check if the www-data user has permission to access postgresql (have a look at /usr/share/doc/openacs/README.Debian) and reinstall the package.

It should work, and start an OpenACS instance at localhost:8000 (by default). If it doesn't, please let us know.

Cheers,

Héctor Romojaro

Collapse
17: Re: DB Connection Error (response to 16)
Posted by Jim Lynch on
Hector, we already know by his log that it's trying to start on port 80; further, it's either not finding nspostgres or its lib.
Collapse
18: Re: DB Connection Error (response to 17)
Posted by Héctor Romojaro on
Hi Jim,

That's exactly why I advised Danny to purge and reinstall the package, because the default install must work with a working postgresql installation (at least with the postgresql debian package, which I guess he is using).

Once it works, changing the config to point to port 80 is simple:

1- Set the RUN_DAEMON var to "no" in /etc/default/aolserver4
2- Set the AOL_PORT (and AOL_ADDRESS, if you want) var to "80" in /etc/aolserver4/conf.d/openacs.sh
3- Restart aolservers with # /etc/init.d/aolserver4 restart

Cheers,

Héctor Romojaro