重新启动ffmpeg进程使用monit [英] Restarting ffmpeg process using monit

查看:226
本文介绍了重新启动ffmpeg进程使用monit的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用monit监视ffmpeg进程。为此,我首先创建了一个具有3个参数(启动,停止和重启)的bash脚本。当我从终端(./ thisBashScript start,./thisBashScript stop和./thisBashScript重新启动)手动运行脚本时,一切都可以完美地完成它的设计。该过程开始,创建并将当前过程id保存到pid文件中。之后,如果我想停止进程,它需要当前的pid文件,并使用给定的pid杀死进程。重新启动也可以正常工作,首先停止并启动该过程。



问题



我安装了监控进程,以防它失败。我配置为以正确的方式检查进程,因为我配置了很好的工作与monit的nginx。



之后,当我使用命令开始进程 ./ thisBashScript start monit开始监视。在monit状态下,进程ffmpeg显示为正在运行。在我使用ffmpeg进程的pid手动杀死进程后,要测试monit是否重新启动进程,那么它不会这样做。即使新的pid被创建并保存在 /var/run/ffmpeg.pid 中。



这里是监控日志:

  [EET Mar 21 12:12:37]错误:'ffmpeg'进程没有运行
[EET Mar 21 12:12:37] info:'ffmpeg'尝试重新启动
[EET Mar 21 12:12:37] info:'ffmpeg'开始:/etc/init.d/iptv/thisBashScript

我有以下bash脚本:

 #$ / 
$ b pid_file =/ var / run / ffmpeg.pid

$ b $ $ b重新启动)
/etc/init.d/iptv/thisBashScript stop
/etc/init.d/iptv/thisBashScript start
;;

start)
rm $ pid_file
ffmpeg -i udp:// @ someIp:1234 -acodec libmp3lame -ac 1 -ar 44100 -ab 64k -s 640x360 -deinterlace - vcodec h264_qsv -vb 700k -f flv rtmp:// someIp / applicationName / 360&
ch_pid = $!
echo启动HLS:ffmpeg = $ ch_pid;
echo $ ch_pid> $ pid_file
;;
stop)
echo停止转码;
kill`cat $ pid_file`
;;

*)
echo用法:/etc/init.d/thisBashScript {start | stop | restart}
exit 1
;;
esac
退出0
echo $ pid_file

此bash脚本可以接受3个参数(开始,重新启动和停止)




  • start(启动ffmpeg命令,在nginx上流式传输视频rtmp服务器);


  • 停止(停止ffmpeg命令);


  • 重启(它停止,然后启动ffmpeg命令);




这是我的monit配置

 检查流程ffmpeg with pidfile /var/run/ffmpeg.pid 
start program =/etc/init.d/iptv/thisBashScript start
stop program =/etc/init.d/iptv/thisBashScript stop


解决方案

通过创建符号链接解决了问题:

  ln -s / opt / intel / mediasdk b b

I am trying to use monit for monitoring the ffmpeg process. For this I first created a bash script that has 3 arguments(start, stop and restart). When I run the script manually from the terminal (./thisBashScript start, ./thisBashScript stop and ./thisBashScript restart ) everything works perfectly how it was designed. The process starts, creates and saves the current procees id into a pid file. After if I want to stop the process it takes the current pid file and and kills the process with the given pid. Restarts also works fine, first it stops and after starts the process.

The problem

I installed monit for monitoring the process in case it goes down. I configured to check the process in the exact manner as I configured nginx that excellent works with monit.

After, when I start the process with the command ./thisBashScript start monit starts monitoring. In monit status the process ffmpeg is showing as running. After I kill the process manually using the pid of ffmpeg process to test if monit restarts the process, it fails to do so. Even though the new pid is created and saved in /var/run/ffmpeg.pid.

Here are the monit logs:

[EET Mar 21 12:12:37] error    : 'ffmpeg' process is not running
[EET Mar 21 12:12:37] info     : 'ffmpeg' trying to restart
[EET Mar 21 12:12:37] info     : 'ffmpeg' start: /etc/init.d/iptv/thisBashScript

I have the following bash script:

 #!/bin/sh

pid_file="/var/run/ffmpeg.pid"

case "$1" in
 restart)
    /etc/init.d/iptv/thisBashScript stop
    /etc/init.d/iptv/thisBashScript start
        ;;

 start)
    rm $pid_file
        ffmpeg -i udp://@someIp:1234 -acodec libmp3lame -ac 1 -ar 44100 -ab 64k -s 640x360 -deinterlace -vcodec h264_qsv -vb 700k -f flv rtmp://someIp/applicationName/360 &
    ch_pid=$! 
    echo "Start HLS: ffmpeg = $ch_pid";
    echo $ch_pid > $pid_file
         ;;
 stop)
    echo "Stop transcoding";
        kill `cat $pid_file`
         ;;

        *)
    echo "Usage: /etc/init.d/thisBashScript {start|stop|restart}"
         exit 1
         ;;
 esac
exit 0
echo $pid_file

This bash script can accept 3 arguments (start, restart and stop)

  • start (it starts the ffmpeg command that streams a video on an nginx rtmp server);

  • stop (it stops the ffmpeg command);

  • restart (it stops and then starts ffmpeg command);

Here is my monit configuration

check process ffmpeg with pidfile /var/run/ffmpeg.pid
    start program = "/etc/init.d/iptv/thisBashScript start"  
    stop program = "/etc/init.d/iptv/thisBashScript stop" 

解决方案

The problem was solved by creating a symlink:

ln -s /opt/intel/mediasdk/lib64/iHD_drv_video.so /usr/local/lib/dri/i965_drv_video.so

这篇关于重新启动ffmpeg进程使用monit的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆