Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
L
lxc
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Chen Yisong
lxc
Commits
f7d85e98
Unverified
Commit
f7d85e98
authored
Mar 31, 2020
by
Christian Brauner
Committed by
GitHub
Mar 31, 2020
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #3342 from Blub/upstream-monitord-service
allow running lxc-monitord as a system daemon
parents
c51c7570
b6278254
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
64 additions
and
21 deletions
+64
-21
.gitignore
.gitignore
+1
-0
Makefile.am
config/init/systemd/Makefile.am
+6
-4
lxc-monitord.service.in
config/init/systemd/lxc-monitord.service.in
+12
-0
configure.ac
configure.ac
+1
-0
lxc.spec.in
lxc.spec.in
+1
-0
lxc_monitord.c
src/lxc/cmd/lxc_monitord.c
+43
-17
No files found.
.gitignore
View file @
f7d85e98
...
@@ -119,6 +119,7 @@ config/bash/lxc
...
@@ -119,6 +119,7 @@ config/bash/lxc
config/init/common/lxc-containers
config/init/common/lxc-containers
config/init/common/lxc-net
config/init/common/lxc-net
config/init/systemd/lxc-autostart-helper
config/init/systemd/lxc-autostart-helper
config/init/systemd/lxc-monitord.service
config/init/systemd/lxc-net.service
config/init/systemd/lxc-net.service
config/init/systemd/lxc.service
config/init/systemd/lxc.service
config/init/systemd/lxc@.service
config/init/systemd/lxc@.service
...
...
config/init/systemd/Makefile.am
View file @
f7d85e98
...
@@ -2,19 +2,21 @@ EXTRA_DIST = \
...
@@ -2,19 +2,21 @@ EXTRA_DIST = \
lxc-apparmor-load
\
lxc-apparmor-load
\
lxc.service.in
\
lxc.service.in
\
lxc@.service.in
\
lxc@.service.in
\
lxc-net.service.in
lxc-net.service.in
\
lxc-monitord.service.in
if
INIT_SCRIPT_SYSTEMD
if
INIT_SCRIPT_SYSTEMD
BUILT_SOURCES
=
lxc.service lxc@.service lxc-net.service
BUILT_SOURCES
=
lxc.service lxc@.service lxc-net.service
lxc-monitord.service
install-systemd
:
lxc.service lxc@.service lxc-net.service lxc-apparmor-load
install-systemd
:
lxc.service lxc@.service lxc-net.service lxc-
monitord.service lxc-
apparmor-load
$(MKDIR_P)
$(DESTDIR)$(SYSTEMD_UNIT_DIR)
$(MKDIR_P)
$(DESTDIR)$(SYSTEMD_UNIT_DIR)
$(INSTALL_DATA)
lxc.service lxc@.service lxc-net.service
$(DESTDIR)$(SYSTEMD_UNIT_DIR)
/
$(INSTALL_DATA)
lxc.service lxc@.service lxc-net.service
lxc-monitord.service
$(DESTDIR)$(SYSTEMD_UNIT_DIR)
/
uninstall-systemd
:
uninstall-systemd
:
rm
-f
$(DESTDIR)$(SYSTEMD_UNIT_DIR)
/lxc.service
rm
-f
$(DESTDIR)$(SYSTEMD_UNIT_DIR)
/lxc.service
rm
-f
$(DESTDIR)$(SYSTEMD_UNIT_DIR)
/lxc@.service
rm
-f
$(DESTDIR)$(SYSTEMD_UNIT_DIR)
/lxc@.service
rm
-f
$(DESTDIR)$(SYSTEMD_UNIT_DIR)
/lxc-net.service
rm
-f
$(DESTDIR)$(SYSTEMD_UNIT_DIR)
/lxc-net.service
rm
-f
$(DESTDIR)$(SYSTEMD_UNIT_DIR)
/lxc-monitord.service
rmdir
$(DESTDIR)$(SYSTEMD_UNIT_DIR)
||
:
rmdir
$(DESTDIR)$(SYSTEMD_UNIT_DIR)
||
:
pkglibexec_SCRIPTS
=
lxc-apparmor-load
pkglibexec_SCRIPTS
=
lxc-apparmor-load
...
...
config/init/systemd/lxc-monitord.service.in
0 → 100644
View file @
f7d85e98
[Unit]
Description=LXC Container Monitoring Daemon
After=syslog.service network.target
[Service]
Type=simple
ExecStart=@LIBEXECDIR@/lxc/lxc-monitord --daemon
StandardOutput=syslog
StandardError=syslog
[Install]
WantedBy=multi-user.target
configure.ac
View file @
f7d85e98
...
@@ -813,6 +813,7 @@ AC_CONFIG_FILES([
...
@@ -813,6 +813,7 @@ AC_CONFIG_FILES([
config/init/systemd/lxc.service
config/init/systemd/lxc.service
config/init/systemd/lxc@.service
config/init/systemd/lxc@.service
config/init/systemd/lxc-net.service
config/init/systemd/lxc-net.service
config/init/systemd/lxc-monitord.service
config/init/sysvinit/Makefile
config/init/sysvinit/Makefile
config/init/sysvinit/lxc-containers
config/init/sysvinit/lxc-containers
config/init/sysvinit/lxc-net
config/init/sysvinit/lxc-net
...
...
lxc.spec.in
View file @
f7d85e98
...
@@ -251,6 +251,7 @@ fi
...
@@ -251,6 +251,7 @@ fi
%{_unitdir}/lxc-net.service
%{_unitdir}/lxc-net.service
%{_unitdir}/lxc.service
%{_unitdir}/lxc.service
%{_unitdir}/lxc@.service
%{_unitdir}/lxc@.service
%{_unitdir}/lxc-monitord.service
%else
%else
%{_sysconfdir}/rc.d/init.d/lxc
%{_sysconfdir}/rc.d/init.d/lxc
%{_sysconfdir}/rc.d/init.d/lxc-net
%{_sysconfdir}/rc.d/init.d/lxc-net
...
...
src/lxc/cmd/lxc_monitord.c
View file @
f7d85e98
...
@@ -338,17 +338,44 @@ static void lxc_monitord_sig_handler(int sig)
...
@@ -338,17 +338,44 @@ static void lxc_monitord_sig_handler(int sig)
int
main
(
int
argc
,
char
*
argv
[])
int
main
(
int
argc
,
char
*
argv
[])
{
{
int
ret
,
pipefd
;
int
ret
,
pipefd
=
-
1
;
char
logpath
[
PATH_MAX
];
char
logpath
[
PATH_MAX
];
sigset_t
mask
;
sigset_t
mask
;
c
har
*
lxcpath
=
argv
[
1
]
;
c
onst
char
*
lxcpath
=
NULL
;
bool
mainloop_opened
=
false
;
bool
mainloop_opened
=
false
;
bool
monitord_created
=
false
;
bool
monitord_created
=
false
;
bool
persistent
=
false
;
struct
lxc_log
log
;
struct
lxc_log
log
;
if
(
argc
!=
3
)
{
if
(
argc
>
1
&&
!
strcmp
(
argv
[
1
],
"--daemon"
))
{
persistent
=
true
;
--
argc
;
++
argv
;
}
if
(
argc
>
1
)
{
lxcpath
=
argv
[
1
];
--
argc
;
++
argv
;
}
else
{
lxcpath
=
lxc_global_config_value
(
"lxc.lxcpath"
);
if
(
!
lxcpath
)
{
ERROR
(
"Failed to get default lxcpath"
);
exit
(
EXIT_FAILURE
);
}
}
if
(
argc
>
1
)
{
if
(
lxc_safe_int
(
argv
[
1
],
&
pipefd
)
<
0
)
exit
(
EXIT_FAILURE
);
--
argc
;
++
argv
;
}
if
(
argc
!=
1
||
(
persistent
!=
(
pipefd
==
-
1
)))
{
fprintf
(
stderr
,
fprintf
(
stderr
,
"Usage: lxc-monitord lxcpath sync-pipe-fd
\n\n
"
"Usage: lxc-monitord lxcpath sync-pipe-fd
\n
"
" lxc-monitord --daemon lxcpath
\n\n
"
"NOTE: lxc-monitord is intended for use by lxc internally
\n
"
"NOTE: lxc-monitord is intended for use by lxc internally
\n
"
" and does not need to be run by hand
\n\n
"
);
" and does not need to be run by hand
\n\n
"
);
exit
(
EXIT_FAILURE
);
exit
(
EXIT_FAILURE
);
...
@@ -371,9 +398,6 @@ int main(int argc, char *argv[])
...
@@ -371,9 +398,6 @@ int main(int argc, char *argv[])
INFO
(
"Failed to open log file %s, log will be lost"
,
lxcpath
);
INFO
(
"Failed to open log file %s, log will be lost"
,
lxcpath
);
lxc_log_options_no_override
();
lxc_log_options_no_override
();
if
(
lxc_safe_int
(
argv
[
2
],
&
pipefd
)
<
0
)
exit
(
EXIT_FAILURE
);
if
(
sigfillset
(
&
mask
)
||
if
(
sigfillset
(
&
mask
)
||
sigdelset
(
&
mask
,
SIGILL
)
||
sigdelset
(
&
mask
,
SIGILL
)
||
sigdelset
(
&
mask
,
SIGSEGV
)
||
sigdelset
(
&
mask
,
SIGSEGV
)
||
...
@@ -406,15 +430,17 @@ int main(int argc, char *argv[])
...
@@ -406,15 +430,17 @@ int main(int argc, char *argv[])
goto
on_error
;
goto
on_error
;
monitord_created
=
true
;
monitord_created
=
true
;
/* sync with parent, we're ignoring the return from write
if
(
pipefd
!=
-
1
)
{
* because regardless if it works or not, the following
/* sync with parent, we're ignoring the return from write
* close will sync us with the parent process. the
* because regardless if it works or not, the following
* if-empty-statement construct is to quiet the
* close will sync us with the parent process. the
* warn-unused-result warning.
* if-empty-statement construct is to quiet the
*/
* warn-unused-result warning.
if
(
lxc_write_nointr
(
pipefd
,
"S"
,
1
))
*/
;
if
(
lxc_write_nointr
(
pipefd
,
"S"
,
1
))
close
(
pipefd
);
;
close
(
pipefd
);
}
if
(
lxc_monitord_mainloop_add
(
&
monitor
))
{
if
(
lxc_monitord_mainloop_add
(
&
monitor
))
{
ERROR
(
"Failed to add mainloop handlers"
);
ERROR
(
"Failed to add mainloop handlers"
);
...
@@ -425,7 +451,7 @@ int main(int argc, char *argv[])
...
@@ -425,7 +451,7 @@ int main(int argc, char *argv[])
lxc_raw_getpid
(),
monitor
.
lxcpath
);
lxc_raw_getpid
(),
monitor
.
lxcpath
);
for
(;;)
{
for
(;;)
{
ret
=
lxc_mainloop
(
&
monitor
.
descr
,
1000
*
30
);
ret
=
lxc_mainloop
(
&
monitor
.
descr
,
persistent
?
-
1
:
1000
*
30
);
if
(
ret
)
{
if
(
ret
)
{
ERROR
(
"mainloop returned an error"
);
ERROR
(
"mainloop returned an error"
);
break
;
break
;
...
...
Write
Preview
Markdown
is supported
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