# 音频对齐服务

# 所需文件

文件描述 文件名 文件位置
服务jar包 audiocompareserver.jar /opt/audio-compare
jar 包配置文件 application.properties /opt/audio-compare
可执行程序 audioCompare /opt/program

# 操作系统

Ubuntu 18.04

# 配置环境

  1. 更新linux安装程序源,安装 jre
apt update
apt upgrade
apt install default-jre
  1. 安装QT和ffmpeg相关库
apt-get install qt5-default
apt install libavutil55
apt install libavcodec57
apt install libavformat57
apt install libswresample2
apt install libswscale4
apt install libqt5multimedia5
apt install libqt5multimedia5-plugins
  1. 安装 xserver 并启动
apt-get install ubuntu-desktop
apt-get install xinit
nohup startx &

# jar 包配置文件

application.properties,需要放在jar包同目录下,或者同目录的config文件夹下,并不是所有的字段都需要,都有默认值,只需要把需要修改的放进来即可。

#端口
server.port=8092
#音频对齐程序的位置
audioComparePath = /opt/program/audioCompare
#下载的音频临时存储的位置
audioPath=/tmp/editor/audio/


#任务调度器的地址,用于和任务调度器保持心跳
task.scheduler.url = http://localhost:9999
#发送心跳的时间间隔,毫秒
heartbeat.fixed.delay = 20000
#服务可同时运行的最大数量
max.execute.count = 10
#服务的ip,用于注册到任务调度器
#能访问到当前服务的url,用于注册到任务调度器
server.url = http://localhost:${server.port}

#连接超时 单位毫秒
connectTimeout = 5000
#从连接池中获取可用连接超时 单位毫秒
connectionRequestTimeout = 5000
#读取超时 单位毫秒
socketTimeout= 5000
#失败后重试次数
httpRequestRetryCount = 3
#失败后睡眠时间 单位毫秒
httpRequestFailSleepTime = 3000 

# 启动服务

切换到jar包的目录下

  1. 查看xserver是否启动
ps -ef| grep xserver
  1. 设置display 环境变量
export DISPLAY=$(ps -ef | grep 'xserver' | grep -v grep |awk '{print $9}')
  1. 启动 java 服务
nohup java -jar audiocompareserver.jar >/dev/null 2>&1 &

# 日志说明

会产生2个日志目录,都会在 /opt/audio-compare目录下。分别是 logs 和 log。 logs 是Java程序产生的日志,每天一个日志文件,只保留最近30天的日志。 log 是audioCompare的产生的日志,每个任务产生一个日志文件。