异步实现执行命令
git clone github.com/juce/sockproc.git
cd sockproc
make
./sockproc /tmp/shell.sock
chmod 0666 /tmp/shell.sock
cd ..
git clone github.com/juce/lua-resty-shell.git
cp lua-resty-shell/lib/resty/shell.lua /usr/local/share/lua/5.1/resty/shell2.lua
cd ..
yum -y localinstall --nogpgcheck download1.rpmfusion.org/free/el/rpmfusion-free-release-7.noarch.rpm
yum -y install ffmpeg ffmpeg-devel
在fastdfs上面添加avinfo功能
location /file1/M00 {
root /data/fastdfs_data/data/;
set $avinfo 0;
if ($args ~ "avinfo"){
set $avinfo "${avinfo}1";
}
if ($uri ~ "/[a-zA-Z0-9]+/[a-zA-Z0-9]+(/[a-zA-Z0-9]+/[a-zA-Z0-9]+.*)") {
set $file $document_root$1;
set $avinfo "${avinfo}1";
}
if ($avinfo = "011") {
content_by_lua '
ngx.header.content_type = "application/json";
local shell = require("resty.shell2");
local args = {
socket = "unix:/tmp/shell.sock",
}
local targetFile = ngx.var.file
local command = "ffprobe -v quiet -print_format json -show_format -show_streams " .. targetFile
local status, out, err = shell.execute(command, args)
--- ngx.say(package.path);
--- ngx.say(package.cpath);
ngx.say(out);
';
}
ngx_fastdfs_module;
}
访问
域名/file1/M00/02/05/oYYBAGAPtsuAdlf1ABj4W8LbwdQ894.mp3?avinfo
阅读(14956) | 评论(0) | 转发(0) |