Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
emulab
emulab-devel
Commits
a7e23a69
Commit
a7e23a69
authored
Jun 13, 2013
by
Srikanth Raju
Committed by
Leigh B Stoller
Jul 23, 2013
Browse files
Elaborate hack to work out args passing and added timeout for pidfile
parent
34e3450c
Changes
1
Hide whitespace changes
Inline
Side-by-side
tmcd/Ec2MetaServer.py.in
View file @
a7e23a69
...
...
@@ -7,7 +7,7 @@ import sys
import
syslog
import
mysql.connector
import
daemon
from
lockfile
import
pid
lock
file
from
daemon
import
pidfile
# This requires Python 2.6+
class
Ec2MetaHandler
(
BaseHTTPRequestHandler
):
...
...
@@ -20,7 +20,30 @@ class Ec2MetaHandler(BaseHTTPRequestHandler):
BaseHTTPRequestHandler
.
__init__
(
self
,
req
,
ca
,
huh
)
def
log_message
(
self
,
format
,
*
args
):
syslog
.
syslog
(
format
.
format
(
args
))
outtext
=
format
alen
=
len
(
args
)
if
alen
==
0
:
outtext
=
format
elif
alen
==
1
:
outtext
=
format
%
(
args
[
0
])
elif
alen
==
2
:
outtext
=
format
%
(
args
[
0
],
args
[
1
])
elif
alen
==
3
:
outtext
=
format
%
(
args
[
0
],
args
[
1
],
args
[
2
])
elif
alen
==
4
:
outtext
=
format
%
(
args
[
0
],
args
[
1
],
args
[
2
],
args
[
3
])
elif
alen
==
5
:
outtext
=
format
%
(
args
[
0
],
args
[
1
],
args
[
2
],
args
[
3
],
args
[
4
])
else
:
outtext
=
"Too many format strings"
# All this retardness is because someone decided that
# that format string functionality was ONLY exposed
# through a shitty operator(%) and not through a real
# function, so now its impossible to use it with *args
# because of some restrictive front end checks, meh
syslog
.
syslog
(
outtext
)
def
do_GET
(
self
):
parsed_path
=
urlparse
.
urlparse
(
self
.
path
)
...
...
@@ -221,10 +244,10 @@ if __name__ == '__main__':
from
BaseHTTPServer
import
HTTPServer
import
socket
metad
=
daemon
.
DaemonContext
()
metad
.
pidfile
=
pid
lock
file
.
PIDLockFile
(
'/var/run/tmcd-meta.pid'
)
sys
log
=
open
(
"@prefix@/log/tmcd-meta.log"
,
"w+"
)
metad
.
stdout
=
sys
log
metad
.
stderr
=
sys
log
metad
.
pidfile
=
pidfile
.
Timeout
PIDLockFile
(
'/var/run/tmcd-meta.pid'
,
acquire_timeout
=
10
)
l
log
=
open
(
"@prefix@/log/tmcd-meta.log"
,
"w+"
)
metad
.
stdout
=
l
log
metad
.
stderr
=
l
log
with
metad
:
server
=
HTTPServer
((
socket
.
gethostbyname
(
socket
.
gethostname
()),
8787
),
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment