Pydap

From GHER

Jump to: navigation, search

Contents

User

create a user and group pydap

sudo adduser --home /var/pydap --no-create-home --group --system pydap

Log directory

Prepare the pydap directory

cd /var/pydap
sudo mkdir log
sudo chown -R pydap.pydap log

Enable on startup

create a file /etc/init.d/pydap

#!/bin/sh -e

### BEGIN INIT INFO
# Provides:          pydap
# Required-Start:    $remote_fs $syslog $network 
# Required-Stop:     $remote_fs $syslog $network 
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Pydap Opendap server
# Description:       Pydap Opendap server
### END INIT INFO

# base dir for pydap

DIR=/var/pydap
INITFILE=$DIR/server/server.ini
LOGFILE=$DIR/log/server.log
PIDFILE=$DIR/log/server.pid
USER=pydap
GROUP=pydap

# enable python virtual environement
. $DIR/env/bin/activate

# writable directory
PYTHON_EGG_CACHE=$DIR/log
export PYTHON_EGG_CACHE

case "$1" in
  start)
    paster serve --daemon --pid-file=$PIDFILE --log-file=$LOGFILE --user=$USER --group=$GROUP $INITFILE start
    ;;
  stop)
    paster serve --daemon --pid-file=$PIDFILE --log-file=$LOGFILE --user=$USER --group=$GROUP  $INITFILE stop
    ;;
  status)
    paster serve --daemon --pid-file=$PIDFILE --log-file=$LOGFILE --user=$USER --group=$GROUP  $INITFILE status
    ;;
  restart)
    paster serve --daemon --pid-file=$PIDFILE --log-file=$LOGFILE --user=$USER --group=$GROUP  $INITFILE restart
    ;;
  *)
    echo $"Usage: $0 {start|stop|restart|status}"
    exit 1
esac

Enable on boot:

update-rc.d pydap defaults


Logging

:/usr/local/lib/python2.7/dist-packages/pydap/handlers# diff -c lib.py.orig lib.py
*** lib.py.orig	2014-05-14 11:40:04.990616056 +0200
--- lib.py	2014-05-14 12:01:31.462675807 +0200
***************
*** 1,6 ****
--- 1,7 ----
  import sys
  import re
  import logging
+ import time
  
  from pkg_resources import iter_entry_points
  from paste.httpexceptions import HTTPException
***************
*** 57,62 ****
--- 58,69 ----
          environ['pydap.ce'] = parse_qs(environ.get('QUERY_STRING', ))
          environ['pydap.logger'] = logging.getLogger('pydap')
          environ['pydap.headers'] = []  # additional headers
+ 
+ 
+         if environ['pydap.response'] == 'dods' or environ['pydap.response'] == 'ascii':            
+             environ['pydap.logger'].warning('access %s %s "%s" "%s" "%s"',time.strftime("%Y-%m-%d %H:%M:%S", time.gmtime()),
+                                             environ['REMOTE_ADDR'],environ['PATH_INFO'],
+                                             environ['QUERY_STRING'],environ['HTTP_USER_AGENT'])
          
          try:
              # Build the dataset using the proper subclass method and

Source

Personal tools