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
Tristan Cavelier
slapos.toolbox
Commits
90cf99b1
Commit
90cf99b1
authored
Nov 15, 2012
by
Alain Takoudjou
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Mecanism for auto truncate slapgrid log
parent
8bab04ab
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
36 additions
and
18 deletions
+36
-18
slapos/runner/static/js/scripts/process.js
slapos/runner/static/js/scripts/process.js
+21
-9
slapos/runner/utils.py
slapos/runner/utils.py
+10
-5
slapos/runner/views.py
slapos/runner/views.py
+5
-4
No files found.
slapos/runner/static/js/scripts/process.js
View file @
90cf99b1
...
...
@@ -44,9 +44,16 @@ function clearAll(setStop) {
running
=
setStop
;
}
function
removeFirstLog
(){
"
use strict
"
;
currentLogSize
-=
parseInt
(
$
(
"
#salpgridLog p:first-child
"
).
attr
(
'
rel
'
),
10
);
$
(
"
#salpgridLog p:first-child
"
).
remove
();
}
function
getRunningState
()
{
"
use strict
"
;
var
size
=
0
;
var
log_info
=
""
;
var
param
=
{
position
:
logReadingPosition
,
log
:
(
processState
!==
"
Checking
"
&&
openedlogpage
===
processType
.
toLowerCase
())
?
openedlogpage
:
""
...
...
@@ -54,10 +61,13 @@ function getRunningState() {
jqxhr
=
$
.
post
(
url
,
param
,
function
(
data
)
{
setRunningState
(
data
);
size
=
data
.
content
.
position
-
logReadingPosition
;
if
(
logReadingPosition
!==
0
&&
data
.
content
.
truncated
){
log_info
=
"
<p class='info' rel='0'>SLAPRUNNER INFO: SLAPGRID-LOG HAS BEEN TRUNCATED HERE. To see full log reload your log page</p>
"
;
}
logReadingPosition
=
data
.
content
.
position
;
if
(
data
.
content
.
content
!==
""
)
{
if
(
data
.
content
.
content
!==
""
)
{
$
(
"
#salpgridLog
"
).
append
(
"
<p rel='
"
+
size
+
"
'>
"
+
data
.
content
.
content
.
toHtmlChar
()
+
"
</p>
"
);
$
(
"
#salpgridLog
"
).
append
(
log_info
+
"
<p rel='
"
+
size
+
"
'>
"
+
data
.
content
.
content
.
toHtmlChar
()
+
"
</p>
"
);
$
(
"
#salpgridLog
"
)
.
scrollTop
(
$
(
"
#salpgridLog
"
)[
0
].
scrollHeight
-
$
(
"
#salpgridLog
"
).
height
());
}
...
...
@@ -67,18 +77,20 @@ function getRunningState() {
$
(
"
#manualLog
"
).
hide
();
}
processState
=
running
?
"
Running
"
:
"
Stopped
"
;
currentLogSize
+=
parseInt
(
size
,
10
);
if
(
currentLogSize
>
maxLogSize
){
//Remove the first element into log div
removeFirstLog
();
if
(
currentLogSize
>
maxLogSize
){
removeFirstLog
();
//in cas of previous <p/> size is 0
}
}
})
.
error
(
function
()
{
clearAll
(
false
);
})
.
complete
(
function
()
{
if
(
running
)
{
currentLogSize
+=
parseInt
(
size
,
10
);
if
(
currentLogSize
>
maxLogSize
){
//Remove the first element into log div
currentLogSize
-=
parseInt
(
$
(
"
#salpgridLog p:first-child
"
).
attr
(
'
rel
'
),
10
);
$
(
"
#salpgridLog p:first-child
"
).
remove
();
}
setTimeout
(
function
()
{
getRunningState
();
},
speed
);
...
...
@@ -95,10 +107,10 @@ function stopProcess() {
sendStop
=
true
;
var
urlfor
=
$SCRIPT_ROOT
+
"
stopSlapgrid
"
,
type
=
"
slapgrid-sr
.pid
"
;
type
=
"
slapgrid-sr
"
;
if
(
$
(
"
#instrun
"
).
text
()
===
"
Stop instance
"
)
{
type
=
"
slapgrid-cp
.pid
"
;
type
=
"
slapgrid-cp
"
;
}
$
.
post
(
urlfor
,
{
type
:
type
},
function
(
data
)
{
//if (data.result) {
...
...
slapos/runner/utils.py
View file @
90cf99b1
...
...
@@ -301,7 +301,6 @@ def runInstanceWithLock(config):
logfile
=
open
(
config
[
'instance_log'
],
'w'
)
if
not
(
updateProxy
(
config
)
and
requestInstance
(
config
)):
return
False
svcStopAll
(
config
)
#prevent lost control of process
slapgrid
=
Popen
([
config
[
'slapgrid_cp'
],
'-vc'
,
'--pidfile'
,
slapgrid_pid
,
config
[
'configuration_file_path'
],
'--now'
],
...
...
@@ -372,8 +371,6 @@ def getSvcStatus(config):
if
item
.
strip
()
!=
""
:
if
re
.
search
(
regex
,
item
,
re
.
IGNORECASE
)
==
None
:
supervisord
.
append
(
re
.
split
(
'[
\
s,]+
'
, item))
else:
return [] #ignore because it is an error message
return supervisord
def getSvcTailProcess(config, process):
...
...
@@ -539,6 +536,12 @@ def newSoftware(folder, config, session):
open(os.path.join(folderPath, config['
software_profile
']), '
w
').write(softwareContent)
open(os.path.join(folderPath, config['
instance_profile
']), '
w
').write("")
open(os.path.join(basedir, ".project"), '
w
').write(folder + "/")
#Clean sapproxy Database
stopProxy(config)
removeProxyDb(config)
startProxy(config)
#Stop runngin process and remove existing instance
removeInstanceRoot(config)
session['
title
'] = getProjectTitle(config)
code = 1
else:
...
...
@@ -623,7 +626,7 @@ def tail(f, lines=20):
block -= 1
return '
\
n
'.join(''.join(data).splitlines()[-lines:])
def readFileFrom(f, lastPosition, limit=
15
000):
def readFileFrom(f, lastPosition, limit=
20
000):
"""
Returns the last lines of file `f`, from position lastPosition.
and the last position
...
...
@@ -635,8 +638,10 @@ def readFileFrom(f, lastPosition, limit=15000):
block = -1
data = ""
length = bytes
truncated = False #True if a part of log data has been truncated
if (lastPosition <= 0 and length > limit) or (length-lastPosition > limit):
lastPosition = length - limit
truncated = True
size = bytes - lastPosition
while bytes > lastPosition:
if abs(block*BUFSIZ) <= size:
...
...
@@ -654,7 +659,7 @@ def readFileFrom(f, lastPosition, limit=15000):
bytes -= BUFSIZ
block -= 1
f.close()
return {"content":data, "position":length}
return {"content":data, "position":length
, "truncated":truncated
}
def isText(file):
"""Return True if the mimetype of file is Text"""
...
...
slapos/runner/views.py
View file @
90cf99b1
...
...
@@ -430,7 +430,7 @@ def getmd5sum():
def
slapgridResult
():
software_state
=
isSoftwareRunning
(
app
.
config
)
instance_state
=
isInstanceRunning
(
app
.
config
)
log_result
=
{
"content"
:
""
,
"position"
:
0
}
log_result
=
{
"content"
:
""
,
"position"
:
0
,
"truncated"
:
False
}
if
request
.
form
[
'log'
]
==
"software"
or
\
request
.
form
[
'log'
]
==
"instance"
:
log_file
=
request
.
form
[
'log'
]
+
"_log"
...
...
@@ -597,8 +597,7 @@ def fileBrowser():
except
:
abort
(
404
)
elif
opt
==
9
:
truncateTo
=
int
(
request
.
form
.
get
(
'truncate'
,
'0'
))
result
=
file_request
.
readFile
(
dir
,
filename
,
truncateTo
)
result
=
file_request
.
readFile
(
dir
,
filename
,
False
)
elif
opt
==
11
:
#Upload file
result
=
file_request
.
uploadFile
(
dir
,
request
.
files
)
...
...
@@ -626,7 +625,9 @@ def editFile():
#Setup List of URLs
app
.
add_url_rule
(
'/'
,
'home'
,
home
)
app
.
add_url_rule
(
'/editSoftwareProfile'
,
'editSoftwareProfile'
,
editSoftwareProfile
)
app
.
add_url_rule
(
'/browseWorkspace'
,
'browseWorkspace'
,
browseWorkspace
)
app
.
add_url_rule
(
'/editSoftwareProfile'
,
'editSoftwareProfile'
,
editSoftwareProfile
)
app
.
add_url_rule
(
'/inspectSoftware'
,
'inspectSoftware'
,
inspectSoftware
)
app
.
add_url_rule
(
'/removeSoftware'
,
'removeSoftware'
,
removeSoftware
)
app
.
add_url_rule
(
'/runSoftwareProfile'
,
'runSoftwareProfile'
,
...
...
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