mirror of
https://github.com/warmcat/libwebsockets.git
synced 2025-03-09 00:00:04 +01:00
introduce daemonize
Signed-off-by: Andy Green <andy.green@linaro.org>
This commit is contained in:
parent
d32bb9128b
commit
279a303662
4 changed files with 34 additions and 0 deletions
|
@ -80,6 +80,9 @@ There are several other possible configure options
|
|||
minimize library footprint for embedded server-only
|
||||
case
|
||||
|
||||
--without-daemonize Don't build daemonize.c / lws_daemonize
|
||||
|
||||
|
||||
Externally configurable important constants
|
||||
-------------------------------------------
|
||||
|
||||
|
@ -206,6 +209,19 @@ configure option --nofork and simply call libwebsocket_service()
|
|||
from your own main loop as shown in the test app sources.
|
||||
|
||||
|
||||
Daemonization
|
||||
-------------
|
||||
|
||||
There's a helper api lws_daemonize built by default that does everything you
|
||||
need to daemonize well, including creating a lock file. If you're making
|
||||
what's basically a daemon, just call this early in your init to fork to a
|
||||
headless background process and exit the starting process.
|
||||
|
||||
Notice stdout, stderr, stdin are all redirected to /dev/null to enforce your
|
||||
daemon is headless, so you'll need to sort out alternative logging, by, eg,
|
||||
syslog.
|
||||
|
||||
|
||||
Fragmented messages
|
||||
-------------------
|
||||
|
||||
|
|
10
configure.ac
10
configure.ac
|
@ -95,6 +95,16 @@ CFLAGS="$CFLAGS -DLWS_NO_CLIENT"
|
|||
fi
|
||||
AM_CONDITIONAL(NO_CLIENT, test x$no_client = xyes)
|
||||
|
||||
#
|
||||
#
|
||||
#
|
||||
AC_ARG_WITH(daemonize,
|
||||
[ --without-daemonize dont build the daemonization api ],
|
||||
[ no_daemonize=yes
|
||||
])
|
||||
|
||||
AM_CONDITIONAL(NO_DAEMONIZE, test x$no_daemonize = xyes)
|
||||
|
||||
#
|
||||
#
|
||||
AC_ARG_ENABLE(mingw,
|
||||
|
|
|
@ -11,6 +11,11 @@ dist_libwebsockets_la_SOURCES=libwebsockets.c \
|
|||
extension-deflate-frame.c extension-deflate-frame.h\
|
||||
private-libwebsockets.h
|
||||
|
||||
if NO_DAEMONIZE
|
||||
else
|
||||
dist_libwebsockets_la_SOURCES+= daemonize.c
|
||||
endif
|
||||
|
||||
if NO_CLIENT
|
||||
else
|
||||
dist_libwebsockets_la_SOURCES+= client.c \
|
||||
|
|
|
@ -818,6 +818,9 @@ LWS_EXTERN int
|
|||
libwebsockets_get_random(struct libwebsocket_context *context,
|
||||
void *buf, int len);
|
||||
|
||||
LWS_EXTERN int
|
||||
lws_daemonize(const char *_lock_path);
|
||||
|
||||
LWS_EXTERN int
|
||||
lws_send_pipe_choked(struct libwebsocket *wsi);
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue