annotate MoinMoin/script/server/standalone.py @ 4261:6de8b4205754

Moved serving-related code into MoinMoin.web.serving module
author Florian Krupicka <florian.krupicka@googlemail.com>
date Sat, 02 Aug 2008 21:37:30 +0200
parents c2ee4633b9e8
children ba0daaf24d63
rev   line source
3025
ccf6d7ffb310 standalone server integrated into 'moin' script command (moin server standalone --help), thanks to Forrest Voight
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
1 # -*- coding: iso-8859-1 -*-
ccf6d7ffb310 standalone server integrated into 'moin' script command (moin server standalone --help), thanks to Forrest Voight
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
2 """
ccf6d7ffb310 standalone server integrated into 'moin' script command (moin server standalone --help), thanks to Forrest Voight
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
3 MoinMoin - run standalone server, optionally daemonizing it
ccf6d7ffb310 standalone server integrated into 'moin' script command (moin server standalone --help), thanks to Forrest Voight
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
4
ccf6d7ffb310 standalone server integrated into 'moin' script command (moin server standalone --help), thanks to Forrest Voight
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
5 @copyright: 2008 MoinMoin:ForrestVoight
ccf6d7ffb310 standalone server integrated into 'moin' script command (moin server standalone --help), thanks to Forrest Voight
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
6 @license: GNU GPL, see COPYING for details.
ccf6d7ffb310 standalone server integrated into 'moin' script command (moin server standalone --help), thanks to Forrest Voight
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
7 """
ccf6d7ffb310 standalone server integrated into 'moin' script command (moin server standalone --help), thanks to Forrest Voight
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
8
ccf6d7ffb310 standalone server integrated into 'moin' script command (moin server standalone --help), thanks to Forrest Voight
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
9 import os
ccf6d7ffb310 standalone server integrated into 'moin' script command (moin server standalone --help), thanks to Forrest Voight
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
10 import sys
ccf6d7ffb310 standalone server integrated into 'moin' script command (moin server standalone --help), thanks to Forrest Voight
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
11 import signal
ccf6d7ffb310 standalone server integrated into 'moin' script command (moin server standalone --help), thanks to Forrest Voight
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
12
ccf6d7ffb310 standalone server integrated into 'moin' script command (moin server standalone --help), thanks to Forrest Voight
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
13 from MoinMoin.script import MoinScript
4228
d9b3c6585585 First implementation of standalone server using werkzeug.serving.run_simple
Florian Krupicka <florian.krupicka@googlemail.com>
parents: 3793
diff changeset
14 from MoinMoin.server.server_standalone import StandaloneConfig
3025
ccf6d7ffb310 standalone server integrated into 'moin' script command (moin server standalone --help), thanks to Forrest Voight
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
15 from MoinMoin.server.daemon import Daemon
4261
6de8b4205754 Moved serving-related code into MoinMoin.web.serving module
Florian Krupicka <florian.krupicka@googlemail.com>
parents: 4252
diff changeset
16 from MoinMoin.web.serving import run_server
3025
ccf6d7ffb310 standalone server integrated into 'moin' script command (moin server standalone --help), thanks to Forrest Voight
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
17
ccf6d7ffb310 standalone server integrated into 'moin' script command (moin server standalone --help), thanks to Forrest Voight
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
18 class PluginScript(MoinScript):
ccf6d7ffb310 standalone server integrated into 'moin' script command (moin server standalone --help), thanks to Forrest Voight
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
19 def __init__(self, argv, def_values):
ccf6d7ffb310 standalone server integrated into 'moin' script command (moin server standalone --help), thanks to Forrest Voight
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
20 MoinScript.__init__(self, argv, def_values)
ccf6d7ffb310 standalone server integrated into 'moin' script command (moin server standalone --help), thanks to Forrest Voight
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
21 self.parser.add_option(
ccf6d7ffb310 standalone server integrated into 'moin' script command (moin server standalone --help), thanks to Forrest Voight
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
22 "--docs", dest="docs",
ccf6d7ffb310 standalone server integrated into 'moin' script command (moin server standalone --help), thanks to Forrest Voight
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
23 help="Set the documents directory. Default: wiki/htdocs or /usr/share/moin/htdocs"
ccf6d7ffb310 standalone server integrated into 'moin' script command (moin server standalone --help), thanks to Forrest Voight
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
24 )
ccf6d7ffb310 standalone server integrated into 'moin' script command (moin server standalone --help), thanks to Forrest Voight
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
25 self.parser.add_option(
ccf6d7ffb310 standalone server integrated into 'moin' script command (moin server standalone --help), thanks to Forrest Voight
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
26 "--user", dest="user",
ccf6d7ffb310 standalone server integrated into 'moin' script command (moin server standalone --help), thanks to Forrest Voight
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
27 help="Set the user to change to. UNIX only. Default: Don't change"
ccf6d7ffb310 standalone server integrated into 'moin' script command (moin server standalone --help), thanks to Forrest Voight
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
28 )
ccf6d7ffb310 standalone server integrated into 'moin' script command (moin server standalone --help), thanks to Forrest Voight
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
29 self.parser.add_option(
ccf6d7ffb310 standalone server integrated into 'moin' script command (moin server standalone --help), thanks to Forrest Voight
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
30 "--group", dest="group",
ccf6d7ffb310 standalone server integrated into 'moin' script command (moin server standalone --help), thanks to Forrest Voight
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
31 help="Set the group to change to. UNIX only. Default: Don't change"
ccf6d7ffb310 standalone server integrated into 'moin' script command (moin server standalone --help), thanks to Forrest Voight
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
32 )
ccf6d7ffb310 standalone server integrated into 'moin' script command (moin server standalone --help), thanks to Forrest Voight
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
33 self.parser.add_option(
ccf6d7ffb310 standalone server integrated into 'moin' script command (moin server standalone --help), thanks to Forrest Voight
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
34 "--port", dest="port", type="int",
ccf6d7ffb310 standalone server integrated into 'moin' script command (moin server standalone --help), thanks to Forrest Voight
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
35 help="Set the port to listen on. Default: 8080"
ccf6d7ffb310 standalone server integrated into 'moin' script command (moin server standalone --help), thanks to Forrest Voight
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
36 )
ccf6d7ffb310 standalone server integrated into 'moin' script command (moin server standalone --help), thanks to Forrest Voight
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
37 self.parser.add_option(
ccf6d7ffb310 standalone server integrated into 'moin' script command (moin server standalone --help), thanks to Forrest Voight
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
38 "--interface", dest="interface",
ccf6d7ffb310 standalone server integrated into 'moin' script command (moin server standalone --help), thanks to Forrest Voight
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
39 help="Set the ip to listen on. Use \"\" for all interfaces. Default: localhost"
ccf6d7ffb310 standalone server integrated into 'moin' script command (moin server standalone --help), thanks to Forrest Voight
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
40 )
ccf6d7ffb310 standalone server integrated into 'moin' script command (moin server standalone --help), thanks to Forrest Voight
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
41 self.parser.add_option(
ccf6d7ffb310 standalone server integrated into 'moin' script command (moin server standalone --help), thanks to Forrest Voight
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
42 "--start", dest="start", action="store_true",
ccf6d7ffb310 standalone server integrated into 'moin' script command (moin server standalone --help), thanks to Forrest Voight
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
43 help="Start server in background."
ccf6d7ffb310 standalone server integrated into 'moin' script command (moin server standalone --help), thanks to Forrest Voight
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
44 )
ccf6d7ffb310 standalone server integrated into 'moin' script command (moin server standalone --help), thanks to Forrest Voight
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
45 self.parser.add_option(
ccf6d7ffb310 standalone server integrated into 'moin' script command (moin server standalone --help), thanks to Forrest Voight
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
46 "--stop", dest="stop", action="store_true",
ccf6d7ffb310 standalone server integrated into 'moin' script command (moin server standalone --help), thanks to Forrest Voight
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
47 help="Stop server in background."
ccf6d7ffb310 standalone server integrated into 'moin' script command (moin server standalone --help), thanks to Forrest Voight
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
48 )
ccf6d7ffb310 standalone server integrated into 'moin' script command (moin server standalone --help), thanks to Forrest Voight
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
49 self.parser.add_option(
ccf6d7ffb310 standalone server integrated into 'moin' script command (moin server standalone --help), thanks to Forrest Voight
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
50 "--pidfile", dest="pidfile",
ccf6d7ffb310 standalone server integrated into 'moin' script command (moin server standalone --help), thanks to Forrest Voight
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
51 help="Set file to store pid of moin daemon in. Default: moin.pid"
ccf6d7ffb310 standalone server integrated into 'moin' script command (moin server standalone --help), thanks to Forrest Voight
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
52 )
4228
d9b3c6585585 First implementation of standalone server using werkzeug.serving.run_simple
Florian Krupicka <florian.krupicka@googlemail.com>
parents: 3793
diff changeset
53 self.parser.add_option(
4248
f35fdfdc1995 Fix missing attributes for standalone server config, remove reloader (crashes currently)
Florian Krupicka <florian.krupicka@googlemail.com>
parents: 4243
diff changeset
54 "--debug", dest="debug", action="store_true",
f35fdfdc1995 Fix missing attributes for standalone server config, remove reloader (crashes currently)
Florian Krupicka <florian.krupicka@googlemail.com>
parents: 4243
diff changeset
55 help="Enable debug mode of server (show tracebacks)"
f35fdfdc1995 Fix missing attributes for standalone server config, remove reloader (crashes currently)
Florian Krupicka <florian.krupicka@googlemail.com>
parents: 4243
diff changeset
56 )
3120
a7c1680aeaa0 PEP8 fixes, mostly whitespace
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3025
diff changeset
57
3025
ccf6d7ffb310 standalone server integrated into 'moin' script command (moin server standalone --help), thanks to Forrest Voight
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
58 def mainloop(self):
ccf6d7ffb310 standalone server integrated into 'moin' script command (moin server standalone --help), thanks to Forrest Voight
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
59 # we don't expect non-option arguments
ccf6d7ffb310 standalone server integrated into 'moin' script command (moin server standalone --help), thanks to Forrest Voight
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
60 if self.args:
ccf6d7ffb310 standalone server integrated into 'moin' script command (moin server standalone --help), thanks to Forrest Voight
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
61 self.parser.error("incorrect number of arguments")
3120
a7c1680aeaa0 PEP8 fixes, mostly whitespace
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3025
diff changeset
62
3025
ccf6d7ffb310 standalone server integrated into 'moin' script command (moin server standalone --help), thanks to Forrest Voight
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
63 pidfile = "moin.pid"
ccf6d7ffb310 standalone server integrated into 'moin' script command (moin server standalone --help), thanks to Forrest Voight
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
64 if self.options.pidfile:
ccf6d7ffb310 standalone server integrated into 'moin' script command (moin server standalone --help), thanks to Forrest Voight
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
65 pidfile = self.options.pidfile
3120
a7c1680aeaa0 PEP8 fixes, mostly whitespace
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3025
diff changeset
66
3025
ccf6d7ffb310 standalone server integrated into 'moin' script command (moin server standalone --help), thanks to Forrest Voight
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
67 if self.options.stop:
ccf6d7ffb310 standalone server integrated into 'moin' script command (moin server standalone --help), thanks to Forrest Voight
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
68 try:
ccf6d7ffb310 standalone server integrated into 'moin' script command (moin server standalone --help), thanks to Forrest Voight
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
69 pids = open(pidfile, "r").read()
ccf6d7ffb310 standalone server integrated into 'moin' script command (moin server standalone --help), thanks to Forrest Voight
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
70 except IOError:
ccf6d7ffb310 standalone server integrated into 'moin' script command (moin server standalone --help), thanks to Forrest Voight
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
71 print "pid file not found (server not running?)"
ccf6d7ffb310 standalone server integrated into 'moin' script command (moin server standalone --help), thanks to Forrest Voight
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
72 else:
ccf6d7ffb310 standalone server integrated into 'moin' script command (moin server standalone --help), thanks to Forrest Voight
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
73 try:
ccf6d7ffb310 standalone server integrated into 'moin' script command (moin server standalone --help), thanks to Forrest Voight
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
74 os.kill(int(pids), signal.SIGTERM)
ccf6d7ffb310 standalone server integrated into 'moin' script command (moin server standalone --help), thanks to Forrest Voight
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
75 except OSError:
ccf6d7ffb310 standalone server integrated into 'moin' script command (moin server standalone --help), thanks to Forrest Voight
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
76 print "kill failed (server not running?)"
ccf6d7ffb310 standalone server integrated into 'moin' script command (moin server standalone --help), thanks to Forrest Voight
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
77 os.remove(pidfile)
ccf6d7ffb310 standalone server integrated into 'moin' script command (moin server standalone --help), thanks to Forrest Voight
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
78 else:
ccf6d7ffb310 standalone server integrated into 'moin' script command (moin server standalone --help), thanks to Forrest Voight
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
79 try:
ccf6d7ffb310 standalone server integrated into 'moin' script command (moin server standalone --help), thanks to Forrest Voight
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
80 if self.options.config_dir:
ccf6d7ffb310 standalone server integrated into 'moin' script command (moin server standalone --help), thanks to Forrest Voight
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
81 sys.path.insert(0, self.options.config_dir)
ccf6d7ffb310 standalone server integrated into 'moin' script command (moin server standalone --help), thanks to Forrest Voight
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
82 from wikiserverconfig import Config
3629
bf72cc397f76 fix some ImportError handlers: SpellCheck is builtin. Don't hide import errors in wikiserverconfig.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3120
diff changeset
83 except ImportError, err:
3893
3be52acb3f43 server.standalone script: fix check for failing import of wikiserverconfig module
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3793
diff changeset
84 if 'wikiserverconfig' in str(err):
3be52acb3f43 server.standalone script: fix check for failing import of wikiserverconfig module
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3793
diff changeset
85 # we are unable to import from wikiserverconfig module
3629
bf72cc397f76 fix some ImportError handlers: SpellCheck is builtin. Don't hide import errors in wikiserverconfig.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3120
diff changeset
86 Config = DefaultConfig
bf72cc397f76 fix some ImportError handlers: SpellCheck is builtin. Don't hide import errors in wikiserverconfig.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3120
diff changeset
87 else:
bf72cc397f76 fix some ImportError handlers: SpellCheck is builtin. Don't hide import errors in wikiserverconfig.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3120
diff changeset
88 # some other import went wrong
bf72cc397f76 fix some ImportError handlers: SpellCheck is builtin. Don't hide import errors in wikiserverconfig.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3120
diff changeset
89 raise
3120
a7c1680aeaa0 PEP8 fixes, mostly whitespace
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3025
diff changeset
90
4243
e116e90ffdec Copy over defaults from DefaultConfig if missing
Florian Krupicka <florian.krupicka@googlemail.com>
parents: 4228
diff changeset
91 # intialize some defaults if missing
4248
f35fdfdc1995 Fix missing attributes for standalone server config, remove reloader (crashes currently)
Florian Krupicka <florian.krupicka@googlemail.com>
parents: 4243
diff changeset
92 for option in ('docs', 'user', 'group', 'port', 'interface', 'debug'):
4243
e116e90ffdec Copy over defaults from DefaultConfig if missing
Florian Krupicka <florian.krupicka@googlemail.com>
parents: 4228
diff changeset
93 if not hasattr(Config, option):
e116e90ffdec Copy over defaults from DefaultConfig if missing
Florian Krupicka <florian.krupicka@googlemail.com>
parents: 4228
diff changeset
94 value = getattr(DefaultConfig, option)
e116e90ffdec Copy over defaults from DefaultConfig if missing
Florian Krupicka <florian.krupicka@googlemail.com>
parents: 4228
diff changeset
95 setattr(Config, option, value)
e116e90ffdec Copy over defaults from DefaultConfig if missing
Florian Krupicka <florian.krupicka@googlemail.com>
parents: 4228
diff changeset
96
e116e90ffdec Copy over defaults from DefaultConfig if missing
Florian Krupicka <florian.krupicka@googlemail.com>
parents: 4228
diff changeset
97 # override with cmdline options
3025
ccf6d7ffb310 standalone server integrated into 'moin' script command (moin server standalone --help), thanks to Forrest Voight
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
98 if self.options.docs:
ccf6d7ffb310 standalone server integrated into 'moin' script command (moin server standalone --help), thanks to Forrest Voight
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
99 Config.docs = self.options.docs
ccf6d7ffb310 standalone server integrated into 'moin' script command (moin server standalone --help), thanks to Forrest Voight
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
100 if self.options.user:
ccf6d7ffb310 standalone server integrated into 'moin' script command (moin server standalone --help), thanks to Forrest Voight
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
101 Config.user = self.options.user
3894
76c3f5181b43 server.standalone script: fix --group option (wasn't used)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3893
diff changeset
102 if self.options.group:
76c3f5181b43 server.standalone script: fix --group option (wasn't used)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3893
diff changeset
103 Config.group = self.options.group
3025
ccf6d7ffb310 standalone server integrated into 'moin' script command (moin server standalone --help), thanks to Forrest Voight
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
104 if self.options.port:
ccf6d7ffb310 standalone server integrated into 'moin' script command (moin server standalone --help), thanks to Forrest Voight
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
105 Config.port = self.options.port
ccf6d7ffb310 standalone server integrated into 'moin' script command (moin server standalone --help), thanks to Forrest Voight
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
106 if self.options.interface:
ccf6d7ffb310 standalone server integrated into 'moin' script command (moin server standalone --help), thanks to Forrest Voight
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
107 Config.interface = self.options.interface
4248
f35fdfdc1995 Fix missing attributes for standalone server config, remove reloader (crashes currently)
Florian Krupicka <florian.krupicka@googlemail.com>
parents: 4243
diff changeset
108 if self.options.debug:
f35fdfdc1995 Fix missing attributes for standalone server config, remove reloader (crashes currently)
Florian Krupicka <florian.krupicka@googlemail.com>
parents: 4243
diff changeset
109 Config.debug = True
4228
d9b3c6585585 First implementation of standalone server using werkzeug.serving.run_simple
Florian Krupicka <florian.krupicka@googlemail.com>
parents: 3793
diff changeset
110
d9b3c6585585 First implementation of standalone server using werkzeug.serving.run_simple
Florian Krupicka <florian.krupicka@googlemail.com>
parents: 3793
diff changeset
111 if not hasattr(Config, 'docs'):
d9b3c6585585 First implementation of standalone server using werkzeug.serving.run_simple
Florian Krupicka <florian.krupicka@googlemail.com>
parents: 3793
diff changeset
112 docs = os.path.join('wiki', 'htdocs')
d9b3c6585585 First implementation of standalone server using werkzeug.serving.run_simple
Florian Krupicka <florian.krupicka@googlemail.com>
parents: 3793
diff changeset
113 if not os.path.exists(docs):
d9b3c6585585 First implementation of standalone server using werkzeug.serving.run_simple
Florian Krupicka <florian.krupicka@googlemail.com>
parents: 3793
diff changeset
114 docs = "/usr/share/moin/htdocs"
d9b3c6585585 First implementation of standalone server using werkzeug.serving.run_simple
Florian Krupicka <florian.krupicka@googlemail.com>
parents: 3793
diff changeset
115 Config.docs = docs
3120
a7c1680aeaa0 PEP8 fixes, mostly whitespace
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3025
diff changeset
116
3025
ccf6d7ffb310 standalone server integrated into 'moin' script command (moin server standalone --help), thanks to Forrest Voight
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
117 if self.options.start:
4228
d9b3c6585585 First implementation of standalone server using werkzeug.serving.run_simple
Florian Krupicka <florian.krupicka@googlemail.com>
parents: 3793
diff changeset
118 daemon = Daemon('moin', pidfile, run_server, Config)
3025
ccf6d7ffb310 standalone server integrated into 'moin' script command (moin server standalone --help), thanks to Forrest Voight
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
119 daemon.do_start()
ccf6d7ffb310 standalone server integrated into 'moin' script command (moin server standalone --help), thanks to Forrest Voight
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
120 else:
4261
6de8b4205754 Moved serving-related code into MoinMoin.web.serving module
Florian Krupicka <florian.krupicka@googlemail.com>
parents: 4252
diff changeset
121 run_server(Config.interface, Config.port, Config.docs,
6de8b4205754 Moved serving-related code into MoinMoin.web.serving module
Florian Krupicka <florian.krupicka@googlemail.com>
parents: 4252
diff changeset
122 use_debugger=Config.debug)
3025
ccf6d7ffb310 standalone server integrated into 'moin' script command (moin server standalone --help), thanks to Forrest Voight
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
123
ccf6d7ffb310 standalone server integrated into 'moin' script command (moin server standalone --help), thanks to Forrest Voight
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
124 class DefaultConfig(StandaloneConfig):
ccf6d7ffb310 standalone server integrated into 'moin' script command (moin server standalone --help), thanks to Forrest Voight
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
125 docs = os.path.join('wiki', 'htdocs')
ccf6d7ffb310 standalone server integrated into 'moin' script command (moin server standalone --help), thanks to Forrest Voight
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
126 if not os.path.exists(docs):
ccf6d7ffb310 standalone server integrated into 'moin' script command (moin server standalone --help), thanks to Forrest Voight
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
127 docs = "/usr/share/moin/htdocs"
ccf6d7ffb310 standalone server integrated into 'moin' script command (moin server standalone --help), thanks to Forrest Voight
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
128 user = ''
ccf6d7ffb310 standalone server integrated into 'moin' script command (moin server standalone --help), thanks to Forrest Voight
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
129 group = ''
ccf6d7ffb310 standalone server integrated into 'moin' script command (moin server standalone --help), thanks to Forrest Voight
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
130 port = 8080
ccf6d7ffb310 standalone server integrated into 'moin' script command (moin server standalone --help), thanks to Forrest Voight
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
131 interface = 'localhost'
4248
f35fdfdc1995 Fix missing attributes for standalone server config, remove reloader (crashes currently)
Florian Krupicka <florian.krupicka@googlemail.com>
parents: 4243
diff changeset
132 debug = False