8687.15.8
by Karl Fogel
Add the copyright header block to more files. |
1 |
# Copyright 2009 Canonical Ltd. This software is licensed under the
|
2 |
# GNU Affero General Public License version 3 (see the file LICENSE).
|
|
1628
by Canonical.com Patch Queue Manager
Configuration, Librian and Librarian test harness work |
3 |
|
1102
by Canonical.com Patch Queue Manager
Lucille had some XXXs which should have been NOTEs |
4 |
# Twisted Application Configuration file.
|
2237
by Canonical.com Patch Queue Manager
[trivial] Libraraian upstream tweaks, which demonstrate the the feature is broken (?) |
5 |
# Use with "twistd2.4 -y <file.tac>", e.g. "twistd -noy server.tac"
|
1102
by Canonical.com Patch Queue Manager
Lucille had some XXXs which should have been NOTEs |
6 |
|
10739.3.1
by Guilherme Salgado
Make the librarian dump its memory (using meliae) upon a 'kill -44' |
7 |
import signal |
8 |
||
9 |
from meliae import scanner |
|
10 |
||
6998.3.2
by Guilherme Salgado
fix the bug. |
11 |
from twisted.application import service, strports |
1102
by Canonical.com Patch Queue Manager
Lucille had some XXXs which should have been NOTEs |
12 |
from twisted.web import server |
13 |
||
4450.7.1
by James Henstridge
move librarian over to use the webapp database adapter |
14 |
from canonical.config import config, dbconfig |
2240
by Canonical.com Patch Queue Manager
My librarian-cleanups branch, held up by baz confusion. r=BjornT |
15 |
from canonical.launchpad.daemons import tachandler |
4450.7.1
by James Henstridge
move librarian over to use the webapp database adapter |
16 |
from canonical.launchpad.scripts import execute_zcml_for_scripts |
1102
by Canonical.com Patch Queue Manager
Lucille had some XXXs which should have been NOTEs |
17 |
|
10739.3.1
by Guilherme Salgado
Make the librarian dump its memory (using meliae) upon a 'kill -44' |
18 |
from canonical.librarian.interfaces import DUMP_FILE, SIGDUMPMEM |
1102
by Canonical.com Patch Queue Manager
Lucille had some XXXs which should have been NOTEs |
19 |
from canonical.librarian.libraryprotocol import FileUploadFactory |
20 |
from canonical.librarian import storage, db |
|
21 |
from canonical.librarian import web as fatweb |
|
11221.1.1
by Robert Collins
Start logging oops from the librarian. Fixes lp:86185 |
22 |
from lp.services.twistedsupport.loggingsupport import set_up_oops_reporting |
1102
by Canonical.com Patch Queue Manager
Lucille had some XXXs which should have been NOTEs |
23 |
|
24 |
# Connect to database
|
|
4450.7.1
by James Henstridge
move librarian over to use the webapp database adapter |
25 |
dbconfig.setConfigSection('librarian') |
26 |
execute_zcml_for_scripts() |
|
1102
by Canonical.com Patch Queue Manager
Lucille had some XXXs which should have been NOTEs |
27 |
|
5863.9.2
by Curtis Hovey
Updated code to use the libraran_server section. |
28 |
path = config.librarian_server.root |
29 |
if config.librarian_server.upstream_host: |
|
30 |
upstreamHost = config.librarian_server.upstream_host |
|
31 |
upstreamPort = config.librarian_server.upstream_port |
|
5911.2.9
by Francis J. Lacoste
Start a restricted librarian in tests. |
32 |
print 'Using upstream librarian http://%s:%d' % ( |
33 |
upstreamHost, upstreamPort) |
|
2109
by Canonical.com Patch Queue Manager
[trivial] Add upstream librarian support for the staging environment |
34 |
else: |
35 |
upstreamHost = upstreamPort = None |
|
6998.3.2
by Guilherme Salgado
fix the bug. |
36 |
|
37 |
application = service.Application('Librarian') |
|
38 |
librarianService = service.IServiceCollection(application) |
|
39 |
||
40 |
# Service that announces when the daemon is ready
|
|
41 |
tachandler.ReadyService().setServiceParent(librarianService) |
|
42 |
||
6998.3.3
by Guilherme Salgado
A couple changes after Francis' review |
43 |
def setUpListener(uploadPort, webPort, restricted): |
44 |
"""Set up a librarian listener on the given ports.
|
|
45 |
||
46 |
:param restricted: Should this be a restricted listener? A restricted
|
|
47 |
listener will serve only files with the 'restricted' file set and all
|
|
48 |
files uploaded through the restricted listener will have that flag
|
|
49 |
set.
|
|
50 |
"""
|
|
51 |
librarian_storage = storage.LibrarianStorage( |
|
52 |
path, db.Library(restricted=restricted)) |
|
53 |
upload_factory = FileUploadFactory(librarian_storage) |
|
54 |
strports.service(str(uploadPort), upload_factory).setServiceParent( |
|
55 |
librarianService) |
|
56 |
root = fatweb.LibraryFileResource( |
|
57 |
librarian_storage, upstreamHost, upstreamPort) |
|
58 |
root.putChild('search', fatweb.DigestSearchResource(librarian_storage)) |
|
59 |
root.putChild('robots.txt', fatweb.robotsTxt) |
|
60 |
site = server.Site(root) |
|
61 |
site.displayTracebacks = False |
|
62 |
strports.service(str(webPort), site).setServiceParent(librarianService) |
|
63 |
||
64 |
# Set up the public librarian.
|
|
6998.3.2
by Guilherme Salgado
fix the bug. |
65 |
uploadPort = config.librarian.upload_port |
66 |
webPort = config.librarian.download_port |
|
6998.3.5
by Guilherme Salgado
Aaaargh |
67 |
setUpListener(uploadPort, webPort, restricted=False) |
6998.3.2
by Guilherme Salgado
fix the bug. |
68 |
|
6998.3.3
by Guilherme Salgado
A couple changes after Francis' review |
69 |
# Set up the restricted librarian.
|
70 |
webPort = config.librarian.restricted_download_port |
|
6998.3.2
by Guilherme Salgado
fix the bug. |
71 |
uploadPort = config.librarian.restricted_upload_port |
6998.3.5
by Guilherme Salgado
Aaaargh |
72 |
setUpListener(uploadPort, webPort, restricted=True) |
10739.3.1
by Guilherme Salgado
Make the librarian dump its memory (using meliae) upon a 'kill -44' |
73 |
|
11221.1.1
by Robert Collins
Start logging oops from the librarian. Fixes lp:86185 |
74 |
# Log OOPS reports
|
75 |
set_up_oops_reporting('librarian', 'librarian') |
|
76 |
||
10739.3.1
by Guilherme Salgado
Make the librarian dump its memory (using meliae) upon a 'kill -44' |
77 |
# Setup a signal handler to dump the process' memory upon 'kill -44'.
|
78 |
def sigdumpmem_handler(signum, frame): |
|
79 |
scanner.dump_all_objects(DUMP_FILE) |
|
80 |
||
81 |
signal.signal(SIGDUMPMEM, sigdumpmem_handler) |