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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
elc
hsh-maxima
Commits
3163f2c6
Commit
3163f2c6
authored
2 years ago
by
Lennart Kramer
Browse files
Options
Downloads
Patches
Plain Diff
refactor some more
parent
6493ef15
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
+9
-11
9 additions, 11 deletions
src/web/web.go
with
9 additions
and
11 deletions
src/web/web.go
+
9
−
11
View file @
3163f2c6
...
@@ -220,11 +220,6 @@ func (p *ChildProcess) eval_command(command string, timeout uint64) MaximaRespon
...
@@ -220,11 +220,6 @@ func (p *ChildProcess) eval_command(command string, timeout uint64) MaximaRespon
return
MaximaResponse
{
&
outbuf
,
float64
(
total
.
Microseconds
())
/
1000
,
nil
}
return
MaximaResponse
{
&
outbuf
,
float64
(
total
.
Microseconds
())
/
1000
,
nil
}
}
}
func
write_500
(
w
http
.
ResponseWriter
)
{
w
.
WriteHeader
(
http
.
StatusInternalServerError
)
fmt
.
Fprint
(
w
,
"500 - internal server error
\n
"
)
}
// kills all processes of user and remove temporary directories
// kills all processes of user and remove temporary directories
func
process_cleanup
(
user
*
User
,
user_queue
chan
<-
*
User
,
tmp_dir
string
)
{
func
process_cleanup
(
user
*
User
,
user_queue
chan
<-
*
User
,
tmp_dir
string
)
{
defer
os
.
RemoveAll
(
tmp_dir
)
defer
os
.
RemoveAll
(
tmp_dir
)
...
@@ -278,7 +273,8 @@ func (req *MaximaRequest) write_timeout_err() {
...
@@ -278,7 +273,8 @@ func (req *MaximaRequest) write_timeout_err() {
}
}
func
(
req
*
MaximaRequest
)
respond_with_error
(
format
string
,
a
...
interface
{})
{
func
(
req
*
MaximaRequest
)
respond_with_error
(
format
string
,
a
...
interface
{})
{
write_500
(
req
.
W
)
req
.
W
.
WriteHeader
(
http
.
StatusInternalServerError
)
fmt
.
Fprint
(
req
.
W
,
"500 - internal server error
\n
"
)
req
.
Metrics
.
NumIntError
.
Inc
()
req
.
Metrics
.
NumIntError
.
Inc
()
req
.
log_with_input
(
format
,
a
...
)
req
.
log_with_input
(
format
,
a
...
)
}
}
...
@@ -329,9 +325,7 @@ func (req *MaximaRequest) WriteResponse(response MaximaResponse) {
...
@@ -329,9 +325,7 @@ func (req *MaximaRequest) WriteResponse(response MaximaResponse) {
return
return
}
}
if
err
!=
nil
{
if
err
!=
nil
{
write_500
(
req
.
W
)
req
.
respond_with_error
(
"Error: Communicating with maxima failed: %s"
,
err
)
req
.
Metrics
.
NumIntError
.
Inc
()
req
.
log_with_input
(
"Error: Communicating with maxima failed: %s"
,
err
)
return
return
}
}
if
req
.
Health
{
if
req
.
Health
{
...
@@ -492,8 +486,7 @@ func get_env_number_positive(varname string, def uint) (uint, error) {
...
@@ -492,8 +486,7 @@ func get_env_number_positive(varname string, def uint) (uint, error) {
return
uint
(
number
),
nil
return
uint
(
number
),
nil
}
}
func
main
()
{
func
init_metrics
()
Metrics
{
// register/initialize various prometheus metrics
metrics
:=
Metrics
{
metrics
:=
Metrics
{
ResponseTime
:
prometheus
.
NewHistogram
(
prometheus
.
HistogramOpts
{
ResponseTime
:
prometheus
.
NewHistogram
(
prometheus
.
HistogramOpts
{
Name
:
"maxima_response_time"
,
Name
:
"maxima_response_time"
,
...
@@ -522,6 +515,11 @@ func main() {
...
@@ -522,6 +515,11 @@ func main() {
prometheus
.
MustRegister
(
metrics
.
NumIntError
)
prometheus
.
MustRegister
(
metrics
.
NumIntError
)
prometheus
.
MustRegister
(
metrics
.
NumTimeout
)
prometheus
.
MustRegister
(
metrics
.
NumTimeout
)
prometheus
.
MustRegister
(
metrics
.
QueueLen
)
prometheus
.
MustRegister
(
metrics
.
QueueLen
)
return
metrics
}
func
main
()
{
metrics
:=
init_metrics
()
if
len
(
os
.
Args
)
!=
2
{
if
len
(
os
.
Args
)
!=
2
{
log
.
Fatal
(
"Fatal: wrong cli-argument usage: web [path to maxima executable]"
)
log
.
Fatal
(
"Fatal: wrong cli-argument usage: web [path to maxima executable]"
)
...
...
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