mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2024-11-22 10:40:05 +08:00
docker 优雅关闭(docker stop graceful) (#2827)
This commit is contained in:
parent
f26e25323f
commit
f69f3b3029
@ -128,4 +128,4 @@ WORKDIR /opt/zlm
|
||||
VOLUME [ "/opt/zlm/conf/","/opt/zlm/log/","opt/zlm/ffmpeg/"]
|
||||
COPY --from=build /opt/build /
|
||||
ENV LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH TZ=Asia/Shanghai
|
||||
CMD ./MediaServer -c ./conf/config.ini
|
||||
CMD ["./MediaServer", "-c" , "./conf/config.ini"]
|
@ -41,4 +41,4 @@ RUN cmake -DCMAKE_BUILD_TYPE=Release .. && \
|
||||
make
|
||||
|
||||
ENV PATH /opt/media/ZLMediaKit/release/linux/Release/:$PATH
|
||||
CMD MediaServer
|
||||
CMD ["MediaServer"]
|
||||
|
@ -60,4 +60,4 @@ RUN apt-get update && \
|
||||
WORKDIR /opt/media/bin/
|
||||
COPY --from=build /opt/media/ZLMediaKit/release/linux/Release/MediaServer /opt/media/bin/MediaServer
|
||||
ENV PATH /opt/media/bin:$PATH
|
||||
CMD MediaServer
|
||||
CMD ["MediaServer"]
|
||||
|
@ -42,4 +42,4 @@ RUN cmake -DCMAKE_BUILD_TYPE=Release .. && \
|
||||
make
|
||||
|
||||
ENV PATH /opt/media/ZLMediaKit/release/linux/Release:$PATH
|
||||
CMD MediaServer
|
||||
CMD ["MediaServer"]
|
||||
|
@ -60,4 +60,4 @@ RUN apt-get update && \
|
||||
WORKDIR /opt/media/bin/
|
||||
COPY --from=build /opt/media/ZLMediaKit/release/linux/Release/MediaServer /opt/media/bin/MediaServer
|
||||
ENV PATH /opt/media/bin:$PATH
|
||||
CMD MediaServer
|
||||
CMD ["MediaServer"]
|
||||
|
@ -83,4 +83,4 @@ COPY --from=build /opt/media/ZLMediaKit/release/linux/${MODEL}/MediaServer /opt/
|
||||
COPY --from=build /opt/media/ZLMediaKit/release/linux/${MODEL}/config.ini /opt/media/conf/
|
||||
COPY --from=build /opt/media/ZLMediaKit/www/ /opt/media/bin/www/
|
||||
ENV PATH /opt/media/bin:$PATH
|
||||
CMD ["sh","-c","./MediaServer -s default.pem -c ../conf/config.ini -l 0"]
|
||||
CMD ["./MediaServer","-s", "default.pem", "-c", "../conf/config.ini", "-l","0"]
|
||||
|
@ -126,6 +126,12 @@ void System::startDaemon(bool &kill_parent_if_failed) {
|
||||
exit(0);
|
||||
});
|
||||
|
||||
signal(SIGTERM,[](int) {
|
||||
WarnL << "收到主动退出信号,关闭父进程与子进程";
|
||||
kill(pid, SIGINT);
|
||||
exit(0);
|
||||
});
|
||||
|
||||
do {
|
||||
int status = 0;
|
||||
if (waitpid(pid, &status, 0) >= 0) {
|
||||
|
@ -420,6 +420,12 @@ int start_main(int argc,char *argv[]) {
|
||||
sem.post();
|
||||
}); // 设置退出信号
|
||||
|
||||
signal(SIGTERM,[](int) {
|
||||
WarnL << "SIGTERM:exit";
|
||||
signal(SIGTERM, SIG_IGN);
|
||||
sem.post();
|
||||
});
|
||||
|
||||
#if !defined(_WIN32)
|
||||
signal(SIGHUP, [](int) { mediakit::loadIniConfig(g_ini_file.data()); });
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user