Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
slapos.core
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Nicolas Wavrant
slapos.core
Commits
5338ee10
Commit
5338ee10
authored
Jan 11, 2013
by
Marco Mariani
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
minor cleanup
parent
d7ba4285
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
19 deletions
+22
-19
slapos/grid/svcbackend.py
slapos/grid/svcbackend.py
+21
-19
slapos/proxy/views.py
slapos/proxy/views.py
+1
-0
No files found.
slapos/grid/svcbackend.py
View file @
5338ee10
# -*- coding: utf-8 -*-
# -*- coding: utf-8 -*-
# vim: set et sts=2:
##############################################################################
##############################################################################
#
#
# Copyright (c) 2010, 2011, 2012 Vifib SARL and Contributors.
# Copyright (c) 2010, 2011, 2012 Vifib SARL and Contributors.
...
@@ -56,7 +57,7 @@ def launchSupervisord(socket, configuration_file):
...
@@ -56,7 +57,7 @@ def launchSupervisord(socket, configuration_file):
while
trynum
<
6
:
while
trynum
<
6
:
try
:
try
:
status
=
supervisor
.
getState
()
status
=
supervisor
.
getState
()
except
xmlrpclib
.
Fault
,
e
:
except
xmlrpclib
.
Fault
as
e
:
if
e
.
faultCode
==
6
and
e
.
faultString
==
'SHUTDOWN_STATE'
:
if
e
.
faultCode
==
6
and
e
.
faultString
==
'SHUTDOWN_STATE'
:
logger
.
info
(
'Supervisor in shutdown procedure, will check again later.'
)
logger
.
info
(
'Supervisor in shutdown procedure, will check again later.'
)
trynum
+=
1
trynum
+=
1
...
@@ -86,12 +87,13 @@ def launchSupervisord(socket, configuration_file):
...
@@ -86,12 +87,13 @@ def launchSupervisord(socket, configuration_file):
configuration_file
+
configuration_file
+
"'] ; supervisor.supervisord.main()"
)
"'] ; supervisor.supervisord.main()"
)
supervisord_popen
=
SlapPopen
(
invocation_list
,
supervisord_popen
=
SlapPopen
(
invocation_list
,
env
=
{},
env
=
{},
executable
=
sys
.
executable
,
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
STDOUT
)
executable
=
sys
.
executable
,
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
STDOUT
)
result
=
supervisord_popen
.
communicate
()[
0
]
result
=
supervisord_popen
.
communicate
()[
0
]
if
supervisord_popen
.
returncode
==
0
:
if
supervisord_popen
.
returncode
==
0
:
log_message
=
'Supervisord command invoked with: %s'
%
result
logger
.
info
(
'Supervisord command invoked with: %s'
%
result
)
logger
.
info
(
log_message
)
try
:
try
:
default_timeout
=
socketlib
.
getdefaulttimeout
()
default_timeout
=
socketlib
.
getdefaulttimeout
()
current_timeout
=
1
current_timeout
=
1
...
@@ -108,7 +110,6 @@ def launchSupervisord(socket, configuration_file):
...
@@ -108,7 +110,6 @@ def launchSupervisord(socket, configuration_file):
except
Exception
:
except
Exception
:
current_timeout
=
5
*
trynum
current_timeout
=
5
*
trynum
trynum
+=
1
trynum
+=
1
pass
else
:
else
:
logger
.
info
(
'Supervisord started correctly in try %s.'
%
trynum
)
logger
.
info
(
'Supervisord started correctly in try %s.'
%
trynum
)
return
return
...
@@ -129,32 +130,32 @@ Typical usage:
...
@@ -129,32 +130,32 @@ Typical usage:
"""
.
strip
()
"""
.
strip
()
parser
=
OptionParser
(
usage
=
usage
)
parser
=
OptionParser
(
usage
=
usage
)
# Parses arguments
# Parses arguments
if
argument_tuple
==
():
if
argument_tuple
:
(
argument_option_instance
,
argument_list
)
=
parser
.
parse_args
(
list
(
argument_tuple
))
else
:
# No arguments given to entry point : we parse sys.argv.
# No arguments given to entry point : we parse sys.argv.
(
argument_option_instance
,
argument_list
)
=
parser
.
parse_args
()
(
argument_option_instance
,
argument_list
)
=
parser
.
parse_args
()
else
:
(
argument_option_instance
,
argument_list
)
=
\
if
not
argument_list
:
parser
.
parse_args
(
list
(
argument_tuple
))
if
len
(
argument_list
)
==
0
:
parser
.
error
(
"Configuration file is obligatory. Consult documentation by "
parser
.
error
(
"Configuration file is obligatory. Consult documentation by "
"calling with -h."
)
"calling with -h."
)
configuration_file
=
argument_list
[
0
]
configuration_file
=
argument_list
[
0
]
if
not
os
.
path
.
exists
(
configuration_file
):
if
not
os
.
path
.
exists
(
configuration_file
):
parser
.
error
(
"Could not read configuration file : %s"
\
parser
.
error
(
"Could not read configuration file : %s"
%
configuration_file
)
%
configuration_file
)
slapgrid_configuration
=
ConfigParser
.
SafeConfigParser
()
slapgrid_configuration
=
ConfigParser
.
SafeConfigParser
()
slapgrid_configuration
.
read
(
configuration_file
)
slapgrid_configuration
.
read
(
configuration_file
)
# Merges the two dictionnaries
# Merges the two dictionnaries
option_dict
=
dict
(
slapgrid_configuration
.
items
(
"slapos"
))
option_dict
=
dict
(
slapgrid_configuration
.
items
(
"slapos"
))
# Supervisord configuration location
# Supervisord configuration location
if
not
option_dict
.
get
(
'supervisord_configuration_path'
):
option_dict
.
setdefault
(
'supervisord_configuration_path'
,
option_dict
[
'supervisord_configuration_path'
]
=
\
os
.
path
.
join
(
option_dict
[
'instance_root'
],
'etc'
,
'supervisord.conf'
))
os
.
path
.
join
(
option_dict
[
'instance_root'
],
'etc'
,
'supervisord.conf'
)
# Supervisord socket
# Supervisord socket
if
not
option_dict
.
get
(
'supervisord_socket'
):
option_dict
.
setdefault
(
'supervisord_socket'
,
option_dict
[
'supervisord_socket'
]
=
\
os
.
path
.
join
(
option_dict
[
'instance_root'
],
'supervisord.socket'
))
os
.
path
.
join
(
option_dict
[
'instance_root'
],
'supervisord.socket'
)
return
option_dict
,
argument_list
[
1
:]
return
option_dict
,
argument_list
[
1
:]
...
@@ -170,3 +171,4 @@ def supervisord(*argument_tuple):
...
@@ -170,3 +171,4 @@ def supervisord(*argument_tuple):
option_dict
,
_
=
getOptionDict
(
*
argument_tuple
)
option_dict
,
_
=
getOptionDict
(
*
argument_tuple
)
launchSupervisord
(
option_dict
[
'supervisord_socket'
],
launchSupervisord
(
option_dict
[
'supervisord_socket'
],
option_dict
[
'supervisord_configuration_path'
])
option_dict
[
'supervisord_configuration_path'
])
slapos/proxy/views.py
View file @
5338ee10
# -*- coding: utf-8 -*-
# -*- coding: utf-8 -*-
# vim: set et sts=2:
##############################################################################
##############################################################################
#
#
# Copyright (c) 2010, 2011, 2012 Vifib SARL and Contributors.
# Copyright (c) 2010, 2011, 2012 Vifib SARL and Contributors.
...
...
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