source: TI05-delivery/trunk/examples/deliveryd.py @ 1538

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/TI05-delivery/trunk/examples/deliveryd.py@1539
Revision 1538, 1.1 KB checked in by spascoe, 14 years ago (diff)

Probably too many changes for one commit :-(.

I've reorganised the auth/authz API to separate interface from
implementation. Some C bug fixes but the example client now segfaults
on exit :-(.

I havn't refactored the test cases to match the new API, so I expect
they fail.

  • Property svn:executable set to *
Line 
1#!/usr/bin/env python
2"""A very simple example of a server.
3
4@author Stephen pascoe
5"""
6
7import sys, os, syslog, stat, time, signal
8from glob import glob
9import re, tempfile, getopt
10
11import logging
12logging.basicConfig(level=logging.DEBUG, filename='./bbftpd.log')
13logger = logging.getLogger('ndg.delivery.server')
14
15import ndg.delivery.server.pybbftp as server
16from ndg.delivery.auth_plugin import *
17
18
19print '''
20===================================
21NDG Delivery Service example server
22===================================
23'''
24
25def after_fork_hook():
26    logging.root.handlers = []
27    logging.basicConfig(level=logging.DEBUG, filename='./bbftpd.log')
28    logger.info('Called after_fork_hook')
29
30logfile = './bbftpd.log'
31n = len(open(logfile).readlines())
32c = server.ServerConnector()
33pid = server.start(AuthHandler(c), ['-l', 'DEBUG'])
34print 'Server process started at pid = %d' % pid
35print 'Monitoring %s' % logfile
36
37try:
38    while 1:
39        newlines = open(logfile).readlines()[n:]
40        n += len(newlines)
41        for line in newlines:
42            print line,
43        time.sleep(2)
44except:
45    os.kill(pid, signal.SIGTERM)
46    print 'Server process killed'
Note: See TracBrowser for help on using the repository browser.