Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
Project
Project
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
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Мажукин
mpd
Commits
7338b16c
Commit
7338b16c
authored
Feb 13, 2012
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
listen: implement systemd socket activation
parent
f5294414
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
94 additions
and
0 deletions
+94
-0
INSTALL
INSTALL
+3
-0
Makefile.am
Makefile.am
+1
-0
NEWS
NEWS
+1
-0
configure.ac
configure.ac
+12
-0
user.xml
doc/user.xml
+41
-0
listen.c
src/listen.c
+36
-0
No files found.
INSTALL
View file @
7338b16c
...
...
@@ -139,6 +139,9 @@ For the sticker database.
libcdio - http://www.gnu.org/software/libcdio/
For playing audio CDs.
libsystemd-daemon - http://freedesktop.org/wiki/Software/systemd/
For systemd activation.
pkg-config
----------
...
...
Makefile.am
View file @
7338b16c
...
...
@@ -34,6 +34,7 @@ src_mpd_LDADD = \
$(FILTER_LIBS)
\
$(ENCODER_LIBS)
\
$(MIXER_LIBS)
\
$(SYSTEMD_DAEMON_LIBS)
\
$(GLIB_LIBS)
mpd_headers
=
\
...
...
NEWS
View file @
7338b16c
...
...
@@ -34,6 +34,7 @@ ver 0.17 (2011/??/??)
* cue: show CUE track numbers
* allow port specification in "bind_to_address" settings
* support floating point samples
* systemd socket activation
ver 0.16.8 (2012/??/??)
...
...
configure.ac
View file @
7338b16c
...
...
@@ -353,6 +353,11 @@ AC_ARG_ENABLE(sqlite,
[enable support for the SQLite database]),,
[enable_sqlite=auto])
AC_ARG_ENABLE(systemd-daemon,
AS_HELP_STRING([--enable-systemd-daemon],
[use the systemd daemon library (default=auto)]),,
[enable_systemd_daemon=auto])
AC_ARG_ENABLE(tcp,
AS_HELP_STRING([--disable-tcp],
[disable support for clients connecting via TCP (default: enable)]),,
...
...
@@ -495,6 +500,13 @@ if
AC_MSG_ERROR([No client interfaces configured!])
fi
MPD_AUTO_PKG(systemd_daemon, SYSTEMD_DAEMON, libsystemd-daemon,
[systemd activation], [libsystemd-daemon not found])
AM_CONDITIONAL(ENABLE_SYSTEMD_DAEMON, test x$enable_systemd_daemon = xyes)
if test x$enable_systemd_daemon = xyes; then
AC_DEFINE([ENABLE_SYSTEMD_DAEMON], 1, [Define to use the systemd daemon library])
fi
dnl ---------------------------------------------------------------------------
dnl LIBC Features
dnl ---------------------------------------------------------------------------
...
...
doc/user.xml
View file @
7338b16c
...
...
@@ -99,6 +99,47 @@ cd mpd-version</programlisting>
<programlisting>
make install
</programlisting>
</section>
<section>
<title><filename>
systemd
</filename>
socket activation
</title>
<para>
Using
<filename>
systemd
</filename>
, you can launch
<filename>
mpd
</filename>
on demand when the first client
attempts to connect. Create two files in
<filename>
/etc/systemd/system/
</filename>
; first
<filename>
mpd.socket
</filename>
:
</para>
<programlisting>
[Socket]
ListenStream=/run/mpd.socket
ListenStream=6600
[Install]
WantedBy=sockets.target
</programlisting>
<para>
Now create
<filename>
mpd.service
</filename>
:
</para>
<programlisting>
[Unit]
Description=Music Player Daemon
After=sound.target
[Service]
ExecStart=/usr/bin/mpd --stdout --no-daemon
</programlisting>
<para>
Start the socket:
</para>
<programlisting>
systemctl enable mpd.socket
systemctl start mpd.socket
</programlisting>
<para>
In this configuration,
<filename>
mpd
</filename>
will ignore
the
<varname>
bind_to_address
</varname>
and
<varname>
port
</varname>
settings.
</para>
</section>
</chapter>
<chapter>
...
...
src/listen.c
View file @
7338b16c
...
...
@@ -28,6 +28,10 @@
#include <string.h>
#include <assert.h>
#ifdef ENABLE_SYSTEMD_DAEMON
#include <systemd/sd-daemon.h>
#endif
#undef G_LOG_DOMAIN
#define G_LOG_DOMAIN "listen"
...
...
@@ -61,6 +65,30 @@ listen_add_config_param(unsigned int port,
}
}
static
bool
listen_systemd_activation
(
GError
**
error_r
)
{
#ifdef ENABLE_SYSTEMD_DAEMON
int
n
=
sd_listen_fds
(
true
);
if
(
n
<=
0
)
{
if
(
n
<
0
)
g_warning
(
"sd_listen_fds() failed: %s"
,
g_strerror
(
-
n
));
return
false
;
}
for
(
int
i
=
SD_LISTEN_FDS_START
,
end
=
SD_LISTEN_FDS_START
+
n
;
i
!=
end
;
++
i
)
if
(
!
server_socket_add_fd
(
listen_socket
,
i
,
error_r
))
return
false
;
return
true
;
#else
(
void
)
error_r
;
return
false
;
#endif
}
bool
listen_global_init
(
GError
**
error_r
)
{
...
...
@@ -72,6 +100,14 @@ listen_global_init(GError **error_r)
listen_socket
=
server_socket_new
(
listen_callback
,
NULL
);
if
(
listen_systemd_activation
(
&
error
))
return
true
;
if
(
error
!=
NULL
)
{
g_propagate_error
(
error_r
,
error
);
return
false
;
}
if
(
param
!=
NULL
)
{
/* "bind_to_address" is configured, create listeners
for all values */
...
...
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