Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
cbmroot
Manage
Activity
Members
Labels
Plan
Wiki
Redmine
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Analyze
Value stream analytics
Contributor analytics
CI/CD 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
Computing
cbmroot
Commits
3c0b9ccf
Commit
3c0b9ccf
authored
11 months ago
by
Jan de Cuveland
Committed by
Pierre-Alain Loizeau
11 months ago
Browse files
Options
Downloads
Patches
Plain Diff
Fix histserv signal handling
parent
16bc84c5
No related branches found
No related tags found
1 merge request
!1820
Fix histserv signal handling
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
services/histserv/app/Application.cxx
+10
-18
10 additions, 18 deletions
services/histserv/app/Application.cxx
services/histserv/app/Application.h
+2
-1
2 additions, 1 deletion
services/histserv/app/Application.h
services/histserv/app/main.cxx
+11
-1
11 additions, 1 deletion
services/histserv/app/main.cxx
with
23 additions
and
20 deletions
services/histserv/app/Application.cxx
+
10
−
18
View file @
3c0b9ccf
...
...
@@ -42,7 +42,9 @@ using cbm::services::histserv::Application;
// ---------------------------------------------------------------------------------------------------------------------
//
Application
::
Application
(
ProgramOptions
const
&
opt
)
:
fOpt
(
opt
)
Application
::
Application
(
ProgramOptions
const
&
opt
,
volatile
sig_atomic_t
*
signalStatus
)
:
fOpt
(
opt
)
,
fSignalStatus
(
signalStatus
)
{
/// Read options from executable
LOG
(
info
)
<<
"Options for Application:"
;
...
...
@@ -84,12 +86,6 @@ Application::Application(ProgramOptions const& opt) : fOpt(opt)
fServer
->
Restrict
(
"/Stop_Server"
,
"allow=admin"
);
}
// Provide signal handling for external interruptions
// NOTE: SZh 02.04.2024:
// This function is needed for ZMQ to throw an exception (zmq::error_t) on the interrupt signal. It seems, that
// the actual body of the function does not matter. This behaviour is not understood.
signal
(
SIGINT
,
[](
int
)
{});
LOG
(
info
)
<<
"JSROOT location: "
<<
jsrootsys
;
}
...
...
@@ -100,7 +96,7 @@ void Application::Exec()
fStopThread
=
false
;
fThread
=
std
::
thread
(
&
Application
::
UpdateHttpServer
,
this
);
LOG
(
info
)
<<
"Listening to ZMQ messages ..."
;
while
(
!
(
fUiCmdActor
->
GetServerStop
())
)
{
//
while
(
!
(
fUiCmdActor
->
GetServerStop
())
&&
*
fSignalStatus
==
0
)
{
try
{
/// Infinite loop, this is a service which should survive until told otherwise after all
/// FIXME: Start listening to <SOMETHING?!?> to receive histograms and configuration
...
...
@@ -111,27 +107,23 @@ void Application::Exec()
if
(
!
ret
)
continue
;
std
::
lock_guard
<
std
::
mutex
>
lk
(
mtx
);
if
(
*
ret
>
3
)
{
//
if
(
*
ret
>
3
)
{
ReceiveConfigAndData
(
vMsg
);
}
else
if
(
*
ret
==
1
)
{
//
else
if
(
*
ret
==
1
)
{
ReceiveData
(
vMsg
[
0
]);
}
else
{
//
else
{
LOG
(
error
)
<<
"Invalid number of message parts received: should be either 1 or more than 3 vs "
<<
*
ret
;
}
}
catch
(
const
zmq
::
error_t
&
err
)
{
if
(
err
.
num
()
==
EINTR
)
{
// FIXME: SZh: Are the socket and the context finished properly?
LOG
(
info
)
<<
"Histogram server execution was interrupted by user. Finishing application"
;
break
;
}
else
{
throw
err
;
if
(
err
.
num
()
!=
EINTR
)
{
throw
;
}
}
}
// FIXME: SZh: Are the socket and the context finished properly?
}
// ---------------------------------------------------------------------------------------------------------------------
...
...
This diff is collapsed.
Click to expand it.
services/histserv/app/Application.h
+
2
−
1
View file @
3c0b9ccf
...
...
@@ -25,7 +25,7 @@ namespace cbm::services::histserv
public:
/** @brief Standard constructor, initialises the application
** @param opt **/
explicit
Application
(
ProgramOptions
const
&
opt
);
explicit
Application
(
ProgramOptions
const
&
opt
,
volatile
sig_atomic_t
*
signalStatus
);
/** @brief Copy constructor forbidden **/
Application
(
const
Application
&
)
=
delete
;
...
...
@@ -84,6 +84,7 @@ namespace cbm::services::histserv
private:
ProgramOptions
const
&
fOpt
;
///< Program options object
volatile
sig_atomic_t
*
fSignalStatus
;
///< Global signal status
THttpServer
*
fServer
=
nullptr
;
///< ROOT Histogram server (JSroot)
std
::
thread
fThread
;
bool
fStopThread
=
false
;
...
...
This diff is collapsed.
Click to expand it.
services/histserv/app/main.cxx
+
11
−
1
View file @
3c0b9ccf
...
...
@@ -5,15 +5,25 @@
#include
"Application.h"
#include
"ProgramOptions.h"
#include
<csignal>
namespace
{
volatile
sig_atomic_t
signal_status
=
0
;
}
static
void
signal_handler
(
int
sig
)
{
signal_status
=
sig
;
}
using
namespace
cbm
::
services
::
histserv
;
int
main
(
int
argc
,
char
*
argv
[])
{
std
::
signal
(
SIGINT
,
signal_handler
);
std
::
signal
(
SIGTERM
,
signal_handler
);
LOG
(
info
)
<<
"***** Histogram server without FairMQ *****"
;
try
{
ProgramOptions
opt
(
argc
,
argv
);
Application
app
(
opt
);
Application
app
(
opt
,
&
signal_status
);
app
.
Exec
();
}
catch
(
std
::
exception
const
&
e
)
{
...
...
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