Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
frama-c
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Model registry
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
pub
frama-c
Commits
06b8d091
Commit
06b8d091
authored
5 years ago
by
Loïc Correnson
Committed by
Michele Alberti
5 years ago
Browse files
Options
Downloads
Patches
Plain Diff
[server/zmq] background server
parent
3e6e1d94
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/plugins/server/main.ml
+1
-0
1 addition, 0 deletions
src/plugins/server/main.ml
src/plugins/server/server_zmq.ml
+47
-23
47 additions, 23 deletions
src/plugins/server/server_zmq.ml
with
48 additions
and
23 deletions
src/plugins/server/main.ml
+
1
−
0
View file @
06b8d091
...
@@ -297,6 +297,7 @@ let stop server =
...
@@ -297,6 +297,7 @@ let stop server =
|
Some
db
->
|
Some
db
->
begin
begin
server
.
background
<-
None
;
server
.
background
<-
None
;
signal
false
;
Db
.
progress
:=
db
;
Db
.
progress
:=
db
;
end
end
...
...
This diff is collapsed.
Click to expand it.
src/plugins/server/server_zmq.ml
+
47
−
23
View file @
06b8d091
...
@@ -32,12 +32,19 @@ module Senv = Server_parameters
...
@@ -32,12 +32,19 @@ module Senv = Server_parameters
let
zmq_group
=
Senv
.
add_group
"Protocol ZeroMQ"
let
zmq_group
=
Senv
.
add_group
"Protocol ZeroMQ"
let
()
=
Parameter_customize
.
set_group
zmq_group
let
()
=
Parameter_customize
.
set_group
zmq_group
module
Enabled
=
Senv
.
String
module
Socket
=
Senv
.
String
(
struct
(
struct
let
option_name
=
"-server-zmq"
let
option_name
=
"-server-zmq"
let
arg_name
=
"url"
let
arg_name
=
"url"
let
default
=
""
let
default
=
""
let
help
=
"Establish a ZeroMQ server and listen for connections"
let
help
=
"Setup the ZeroMQ server (in background)."
end
)
let
()
=
Parameter_customize
.
set_group
zmq_group
module
Run
=
Senv
.
Action
(
struct
let
option_name
=
"-server-zmq-run"
let
help
=
"Launch the ZeroMQ server (until shutdown)."
end
)
end
)
let
_
=
Doc
.
page
`Protocol
~
title
:
"ZeroMQ Protocol"
~
filename
:
"server_zmq.md"
let
_
=
Doc
.
page
`Protocol
~
title
:
"ZeroMQ Protocol"
~
filename
:
"server_zmq.md"
...
@@ -46,7 +53,7 @@ let _ = Doc.page `Protocol ~title:"ZeroMQ Protocol" ~filename:"server_zmq.md"
...
@@ -46,7 +53,7 @@ let _ = Doc.page `Protocol ~title:"ZeroMQ Protocol" ~filename:"server_zmq.md"
(* --- ZMQ Context --- *)
(* --- ZMQ Context --- *)
(* -------------------------------------------------------------------------- *)
(* -------------------------------------------------------------------------- *)
let
context
=
let
zmq_
context
=
let
zmq
=
ref
None
in
let
zmq
=
ref
None
in
fun
()
->
fun
()
->
match
!
zmq
with
match
!
zmq
with
...
@@ -117,26 +124,43 @@ let fetch socket () =
...
@@ -117,26 +124,43 @@ let fetch socket () =
(* --- Establish the Server --- *)
(* --- Establish the Server --- *)
(* -------------------------------------------------------------------------- *)
(* -------------------------------------------------------------------------- *)
let
establish
url
=
let
pretty
=
Format
.
pp_print_string
if
url
<>
""
then
let
background
=
ref
None
begin
let
context
=
context
()
in
let
socket
=
Zmq
.
Socket
.(
create
context
rep
)
in
try
Zmq
.
Socket
.
bind
socket
url
;
Senv
.
feedback
"ZeroMQ [%s]"
url
;
Main
.
create
~
pretty
:
Format
.
pp_print_string
~
fetch
:
(
fetch
socket
)
()
|>
Main
.
run
;
Zmq
.
Socket
.
close
socket
;
with
exn
->
Zmq
.
Socket
.
close
socket
;
raise
exn
end
(* -------------------------------------------------------------------------- *)
let
cmdline
()
=
(* --- Establish the Server from Command line --- *)
begin
(* -------------------------------------------------------------------------- *)
match
!
background
with
|
Some
server
->
let
()
=
Db
.
Main
.
extend
(
fun
()
->
establish
(
Enabled
.
get
()
))
if
Run
.
get
()
then
Main
.
run
server
|
None
->
let
url
=
Socket
.
get
()
in
if
url
<>
""
then
let
context
=
zmq_context
()
in
let
socket
=
Zmq
.
Socket
.(
create
context
rep
)
in
try
Zmq
.
Socket
.
bind
socket
url
;
let
server
=
Main
.
create
~
pretty
~
fetch
:
(
fetch
socket
)
()
in
background
:=
Some
server
;
at_exit
begin
fun
()
->
Senv
.
feedback
"ZeroMQ [%s] stopped"
url
;
Zmq
.
Socket
.
close
socket
;
background
:=
None
;
end
;
if
Run
.
get
()
then
begin
Senv
.
feedback
"ZeroMQ [%s] running"
url
;
Main
.
run
server
end
else
begin
Senv
.
feedback
"ZeroMQ [%s] started"
url
;
Main
.
start
server
end
with
exn
->
Zmq
.
Socket
.
close
socket
;
raise
exn
end
let
()
=
Db
.
Main
.
extend
cmdline
(* -------------------------------------------------------------------------- *)
(* -------------------------------------------------------------------------- *)
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