Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
H
hsh-maxima
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
elc
hsh-maxima
Commits
b0428316
Commit
b0428316
authored
4 years ago
by
Lennart Kramer
Browse files
Options
Downloads
Patches
Plain Diff
try doing healthcheck
parent
001c30f1
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/web/web.go
+25
-1
25 additions, 1 deletion
src/web/web.go
with
25 additions
and
1 deletion
src/web/web.go
+
25
−
1
View file @
b0428316
...
@@ -259,6 +259,12 @@ func handler(w http.ResponseWriter, r *http.Request, queue <-chan *ChildProcess,
...
@@ -259,6 +259,12 @@ func handler(w http.ResponseWriter, r *http.Request, queue <-chan *ChildProcess,
log
.
Printf
(
"Warn: Invalid timeout: %s"
,
err
)
log
.
Printf
(
"Warn: Invalid timeout: %s"
,
err
)
return
return
}
}
health
:=
r
.
FormValue
(
"health"
)
if
health
==
"1"
{
input
=
"print(
\"
healthcheck successful
\"
);"
timeout
=
1000
debugf
(
"Debug: doing healthcheck"
)
}
if
timeout
>
30000
{
if
timeout
>
30000
{
log
.
Printf
(
"Warn: timeout %d was out of range range, reduced to 30000"
,
timeout
)
log
.
Printf
(
"Warn: timeout %d was out of range range, reduced to 30000"
,
timeout
)
...
@@ -293,6 +299,21 @@ func handler(w http.ResponseWriter, r *http.Request, queue <-chan *ChildProcess,
...
@@ -293,6 +299,21 @@ func handler(w http.ResponseWriter, r *http.Request, queue <-chan *ChildProcess,
log
.
Printf
(
"Error: Communicating with maxima failed: %s"
,
err
)
log
.
Printf
(
"Error: Communicating with maxima failed: %s"
,
err
)
return
return
}
}
if
health
==
"1"
{
if
bytes
.
Contains
(
outbuf
.
Bytes
(),
[]
byte
(
"healthcheck successful"
))
{
w
.
Header
()
.
Set
(
"Content-Type"
,
"text/plain;charset=UTF-8"
)
outbuf
.
WriteTo
(
w
)
debugf
(
"Healthcheck passed"
)
// note: we don't update metrics here since they would get
// too polluted by the healthchecks
return
}
else
{
write_500
(
w
)
metrics
.
NumIntError
.
Inc
()
log
.
Printf
(
"Error: Healthcheck did not pass"
)
return
}
}
output_dir
:=
filepath
.
Clean
(
filepath
.
Join
(
proc
.
TempDir
,
"output"
))
+
"/"
output_dir
:=
filepath
.
Clean
(
filepath
.
Join
(
proc
.
TempDir
,
"output"
))
+
"/"
// if there are any files inside the output dir, we give back a zip file containing all output
// if there are any files inside the output dir, we give back a zip file containing all output
// files and the command output inside a file named OUTPUT
// files and the command output inside a file named OUTPUT
...
@@ -317,6 +338,7 @@ func handler(w http.ResponseWriter, r *http.Request, queue <-chan *ChildProcess,
...
@@ -317,6 +338,7 @@ func handler(w http.ResponseWriter, r *http.Request, queue <-chan *ChildProcess,
out
,
err
:=
zipfile
.
Create
(
"OUTPUT"
)
out
,
err
:=
zipfile
.
Create
(
"OUTPUT"
)
if
err
!=
nil
{
if
err
!=
nil
{
write_500
(
w
)
write_500
(
w
)
metrics
.
NumIntError
.
Inc
()
log
.
Printf
(
"Error: Could not add OUTPUT to zip archive: %s"
,
err
)
log
.
Printf
(
"Error: Could not add OUTPUT to zip archive: %s"
,
err
)
return
return
}
}
...
@@ -328,12 +350,14 @@ func handler(w http.ResponseWriter, r *http.Request, queue <-chan *ChildProcess,
...
@@ -328,12 +350,14 @@ func handler(w http.ResponseWriter, r *http.Request, queue <-chan *ChildProcess,
defer
ffilein
.
Close
()
defer
ffilein
.
Close
()
if
err
!=
nil
{
if
err
!=
nil
{
write_500
(
w
)
write_500
(
w
)
metrics
.
NumIntError
.
Inc
()
log
.
Printf
(
"Error: could not open plot %s: %s"
,
file
.
Name
(),
err
)
log
.
Printf
(
"Error: could not open plot %s: %s"
,
file
.
Name
(),
err
)
return
return
}
}
fzipput
,
err
:=
zipfile
.
Create
(
"/"
+
file
.
Name
())
fzipput
,
err
:=
zipfile
.
Create
(
"/"
+
file
.
Name
())
if
err
!=
nil
{
if
err
!=
nil
{
write_500
(
w
)
write_500
(
w
)
metrics
.
NumIntError
.
Inc
()
log
.
Printf
(
"Error: could not add file %s to zip archive: %s"
,
file
.
Name
(),
err
)
log
.
Printf
(
"Error: could not add file %s to zip archive: %s"
,
file
.
Name
(),
err
)
return
return
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment