shellUtil.js 1.6 KB
const callfile = require('child_process');
const recordInfo =require( '../../../model/RecordInfoModel');
const recordStatus =require( '../../../model/RecordStatusModel')
const uuid = require('../../UuidUtil');
const moment = require('moment')


function shell(){

}

shell.prototype.Recording =async(appId,uid,channel,channelKey,body)=>{
    // return new Promise((resolve, reject) =>{
        try {
            body.id =   uuid.db32() 
            body.createTime = new Date().getTime();
            var channelInfo =  await recordStatus.findOne({where:{channel:channel}});
            let  r =  await recordInfo.create(body);            
            if(channelInfo){
                if(channelInfo.status == 0){
                    var channelInfo =  await recordStatus.update({status:1},{where:{channel:channel}}); 
                }else if(channelInfo.status == 1){
                    throw  false ;                    
                }
            }else{
                var channelInfo =  await recordStatus.create({id:uuid.db32(),channel:channel,status:1});                 
            }
            let  shell =`cd /netWorkSchool/Agora_Recording_SDK_for_Linux_FULL/samples/ && ./Recorder_local`+
            ` --appId  ` +appId +
            //` --uid ` +uid +
            ` --channel ` +  channel +
            //` --channelKey ` + channelKey +        
            " --appliteDir  \`pwd\`/../bin";
    console.log(shell)
            
        await callfile.exec(shell)
            return true
        } catch (error) {
            throw error
        }
        
    // })
   
}


module.exports = new shell();