Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
slapos.toolbox
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
Kirill Smelkov
slapos.toolbox
Commits
48d60d0f
Commit
48d60d0f
authored
Oct 21, 2013
by
Nicolas Wavrant
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
slaprunner: must now be launched using wsgi
parent
7d35988b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
36 deletions
+27
-36
slapos/runner/__init__.py
slapos/runner/__init__.py
+26
-35
slapos/runner/utils.py
slapos/runner/utils.py
+1
-1
No files found.
slapos/runner/__init__.py
View file @
48d60d0f
...
@@ -8,10 +8,11 @@ import logging
...
@@ -8,10 +8,11 @@ import logging
import
logging.handlers
import
logging.handlers
from
optparse
import
OptionParser
,
Option
from
optparse
import
OptionParser
,
Option
import
os
import
os
import
slapos.runner.process
from
slapos.runner.process
import
setHandler
import
sys
import
sys
from
slapos.runner.utils
import
(
runInstanceWithLock
,
from
slapos.runner.utils
import
(
runInstanceWithLock
,
cloneDefaultGit
,
setupDefaultSR
)
cloneDefaultGit
,
setupDefaultSR
)
from
slapos.runner.views
import
*
class
Parser
(
OptionParser
):
class
Parser
(
OptionParser
):
...
@@ -62,19 +63,15 @@ class Config:
...
@@ -62,19 +63,15 @@ class Config:
self
.
logger
=
None
self
.
logger
=
None
self
.
verbose
=
None
self
.
verbose
=
None
def
setConfig
(
self
,
option_dict
,
configuration_file_path
):
def
setConfig
(
self
):
"""
"""
Set options given by parameters.
Set options given by parameters.
"""
"""
self
.
configuration_file_path
=
os
.
path
.
abspath
(
configuration_file_path
)
self
.
configuration_file_path
=
os
.
path
.
abspath
(
os
.
getenv
(
'RUNNER_CONFIG'
))
# Set options parameters
for
option
,
value
in
option_dict
.
__dict__
.
items
():
setattr
(
self
,
option
,
value
)
# Load configuration file
# Load configuration file
configuration_parser
=
ConfigParser
.
SafeConfigParser
()
configuration_parser
=
ConfigParser
.
SafeConfigParser
()
configuration_parser
.
read
(
configuration_file_path
)
configuration_parser
.
read
(
self
.
configuration_file_path
)
# Merges the arguments and configuration
for
section
in
(
"slaprunner"
,
"slapos"
,
"slapproxy"
,
"slapformat"
,
for
section
in
(
"slaprunner"
,
"slapos"
,
"slapproxy"
,
"slapformat"
,
"sshkeys_authority"
,
"gitclient"
,
"cloud9_IDE"
):
"sshkeys_authority"
,
"gitclient"
,
"cloud9_IDE"
):
...
@@ -89,17 +86,17 @@ class Config:
...
@@ -89,17 +86,17 @@ class Config:
if
self
.
console
:
if
self
.
console
:
self
.
logger
.
addHandler
(
logging
.
StreamHandler
())
self
.
logger
.
addHandler
(
logging
.
StreamHandler
())
if
self
.
log_file
:
self
.
log_file
=
self
.
log_dir
+
'/slaprunner.log'
if
not
os
.
path
.
isdir
(
os
.
path
.
dirname
(
self
.
log_file
)):
if
not
os
.
path
.
isdir
(
os
.
path
.
dirname
(
self
.
log_file
)):
# fallback to console only if directory for logs does not exists and
# fallback to console only if directory for logs does not exists and
# continue to run
# continue to run
raise
ValueError
(
'Please create directory %r to store %r log file'
%
(
raise
ValueError
(
'Please create directory %r to store %r log file'
%
(
os
.
path
.
dirname
(
self
.
log_file
),
self
.
log_file
))
os
.
path
.
dirname
(
self
.
log_file
),
self
.
log_file
))
else
:
else
:
file_handler
=
logging
.
FileHandler
(
self
.
log_file
)
file_handler
=
logging
.
FileHandler
(
self
.
log_file
)
file_handler
.
setFormatter
(
logging
.
Formatter
(
"%(asctime)s - %(name)s - %(levelname)s - %(message)s"
))
file_handler
.
setFormatter
(
logging
.
Formatter
(
"%(asctime)s - %(name)s - %(levelname)s - %(message)s"
))
self
.
logger
.
addHandler
(
file_handler
)
self
.
logger
.
addHandler
(
file_handler
)
self
.
logger
.
info
(
'Configured logging to file %r'
%
self
.
log_file
)
self
.
logger
.
info
(
'Configured logging to file %r'
%
self
.
log_file
)
self
.
logger
.
info
(
"Started."
)
self
.
logger
.
info
(
"Started."
)
self
.
logger
.
info
(
os
.
environ
[
'PATH'
])
self
.
logger
.
info
(
os
.
environ
[
'PATH'
])
...
@@ -115,23 +112,19 @@ def run():
...
@@ -115,23 +112,19 @@ def run():
try
:
try
:
# Parse arguments
# Parse arguments
config
=
Config
()
config
=
Config
()
config
.
setConfig
(
*
Parser
(
usage
=
usage
).
check_args
()
)
config
.
setConfig
()
if
os
.
getuid
()
==
0
:
if
os
.
getuid
()
==
0
:
# avoid mistakes (mainly in development mode)
# avoid mistakes (mainly in development mode)
raise
Exception
(
'Do not run SlapRunner as root.'
)
raise
Exception
(
'Do not run SlapRunner as root.'
)
serve
(
config
)
serve
(
config
)
return_code
=
0
return_code
=
0
except
SystemExit
as
err
:
except
:
# Catch exception raise by optparse
e
=
sys
.
exc_info
()[
0
]
return_code
=
err
sys
.
exit
(
e
)
sys
.
exit
(
return_code
)
def
serve
(
config
):
def
serve
(
config
):
from
views
import
app
from
werkzeug.contrib.fixers
import
ProxyFix
from
werkzeug.contrib.fixers
import
ProxyFix
workdir
=
os
.
path
.
join
(
config
.
runner_workdir
,
'project'
)
workdir
=
os
.
path
.
join
(
config
.
runner_workdir
,
'project'
)
software_link
=
os
.
path
.
join
(
config
.
runner_workdir
,
'softwareLink'
)
software_link
=
os
.
path
.
join
(
config
.
runner_workdir
,
'softwareLink'
)
...
@@ -150,12 +143,10 @@ def serve(config):
...
@@ -150,12 +143,10 @@ def serve(config):
os
.
mkdir
(
workdir
)
os
.
mkdir
(
workdir
)
if
not
os
.
path
.
exists
(
software_link
):
if
not
os
.
path
.
exists
(
software_link
):
os
.
mkdir
(
software_link
)
os
.
mkdir
(
software_link
)
s
lapos
.
runner
.
process
.
s
etHandler
()
setHandler
()
config
.
logger
.
info
(
'Running slapgrid...'
)
config
.
logger
.
info
(
'Running slapgrid...'
)
##runInstanceWithLock(app.config)
runInstanceWithLock
(
app
.
config
)
##cloneDefaultGit(app.config)
##setupDefaultSR(app.config)
config
.
logger
.
info
(
'Done.'
)
config
.
logger
.
info
(
'Done.'
)
app
.
wsgi_app
=
ProxyFix
(
app
.
wsgi_app
)
app
.
wsgi_app
=
ProxyFix
(
app
.
wsgi_app
)
app
.
run
(
host
=
config
.
runner_host
,
port
=
int
(
config
.
runner_port
),
debug
=
config
.
debug
,
threaded
=
True
)
run
(
)
slapos/runner/utils.py
View file @
48d60d0f
...
@@ -340,7 +340,7 @@ def runInstanceWithLock(config):
...
@@ -340,7 +340,7 @@ def runInstanceWithLock(config):
slapgrid
=
Popen
([
config
[
'slapgrid_cp'
],
'-vc'
,
slapgrid
=
Popen
([
config
[
'slapgrid_cp'
],
'-vc'
,
'--pidfile'
,
slapgrid_pid
,
'--pidfile'
,
slapgrid_pid
,
config
[
'configuration_file_path'
],
'--now'
],
config
[
'configuration_file_path'
],
'--now'
],
stdout
=
logfile
,
name
=
'slapgrid-cp'
)
stdout
=
logfile
,
name
=
'slapgrid-cp'
)
slapgrid
.
wait
()
slapgrid
.
wait
()
return
True
return
True
...
...
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