Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Fardale
ocluster
Commits
215e555f
Commit
215e555f
authored
Mar 05, 2019
by
Fardale
Browse files
Use async in the master and add parallelism
parent
331d68ad
Changes
1
Hide whitespace changes
Inline
Side-by-side
master.ml
View file @
215e555f
...
...
@@ -69,33 +69,34 @@ let server_handler pass port sockaddr (ic, _oc) =
|
Result
.
Ok
query
->
(
match
query
with
|
`RESULT
result
->
if
pass
=
result
.
pass
then
(
(*Lwt_io.write oc "true"
<&>*)
Logs_lwt
.
debug
(
fun
m
->
m
"Receive result: %s
\n
"
(
Serialization_j
.
string_of_result
{
result
with
stdout
=
"<stdout>"
;
stderr
=
"<stderr>"
})
)
>>=
fun
()
->
Lwt_io
.
with_file
~
mode
:
Lwt_io
.
output
(
Printf
.
sprintf
"ocluster_%i_%i.out"
(
fst
result
.
id
)
(
snd
result
.
id
))
(
fun
oc
->
Lwt_io
.
write
oc
result
.
stdout
)
>>=
fun
()
->
Lwt_io
.
with_file
~
mode
:
Lwt_io
.
output
(
Printf
.
sprintf
"ocluster_%i_%i.err"
(
fst
result
.
id
)
(
snd
result
.
id
))
(
fun
oc
->
Lwt_io
.
write
oc
result
.
stderr
)
if
pass
=
result
.
pass
then
Logs_lwt
.
debug
(
fun
m
->
m
"Receive result: %s
\n
"
(
Serialization_j
.
string_of_result
{
result
with
stdout
=
"<stdout>"
;
stderr
=
"<stderr>"
})
)
>>=
fun
()
->
Lwt_io
.
with_file
~
mode
:
Lwt_io
.
output
(
Printf
.
sprintf
"ocluster_%i_%i.log"
(
fst
result
.
id
)
(
snd
result
.
id
))
(
fun
oc
->
Lwt_io
.
write
oc
(
Printf
.
sprintf
"Job completed at %f
\n
Return code: %s
\n
"
(
Unix
.
time
()
)
(
string_of_ret_code
result
.
ret_code
))
)
>>=
fun
()
->
end_job
result
.
id
sockaddr
;
launch_job
()
)
Lwt
.
return
(
Lwt
.
async
(
fun
()
->
Lwt
.
join
[
Lwt_io
.
with_file
~
mode
:
Lwt_io
.
output
(
Printf
.
sprintf
"ocluster_%i_%i.out"
(
fst
result
.
id
)
(
snd
result
.
id
))
(
fun
oc
->
Lwt_io
.
write
oc
result
.
stdout
)
;
Lwt_io
.
with_file
~
mode
:
Lwt_io
.
output
(
Printf
.
sprintf
"ocluster_%i_%i.err"
(
fst
result
.
id
)
(
snd
result
.
id
))
(
fun
oc
->
Lwt_io
.
write
oc
result
.
stderr
)
;
Lwt_io
.
with_file
~
mode
:
Lwt_io
.
output
(
Printf
.
sprintf
"ocluster_%i_%i.log"
(
fst
result
.
id
)
(
snd
result
.
id
))
(
fun
oc
->
Lwt_io
.
write
oc
(
Printf
.
sprintf
"Job completed at %f
\n
Return code: %s
\n
"
(
Unix
.
time
()
)
(
string_of_ret_code
result
.
ret_code
))
)
;
end_job
result
.
id
sockaddr
>>=
Lwt
.
pause
>>=
launch_job
]
))
else
(*Lwt_io.write oc "Wrong password"
<&>*)
...
...
Write
Preview
Supports
Markdown
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