이번에 저희 앱에 비디오 컨텐츠 포스팅 기능을 추가하느라…
클라우드용 트랜스코더를 이용을 했는데…
트랜스코딩 결과를 받기위해서는 특정포트(3000번)로 http post를 처리해줄 서버가 필요하더군요.
따로 그거만 처리하는 웹서버를 만들기 거시기 해서…걍 parse server에 http 서버를 추가해서 아래와 같이 만들었습니다.
app.post('/zencoder', function(req, res) {
req.accepts('application/json');
// input message handling
var json = req.body;
var jobId = json.job.id.toString();
console.log("zencoder notification job id:" + jobId + ", status:" + json.job.state);
// doing something...
res.status(202).send( {message: "Thanks, Zencoder! We will take it from here."});
});
var port = process.env.PORT || 1337;
var httpServer = require('http').createServer(app);
httpServer.listen(port, function() {
console.log('parse-server-example running on port ' + port + '.');
});
var httpServer2 = require('http').createServer(app);
httpServer2.listen(3000, function() {
console.log("zencoder notifications ready on port 3000");
});
테스트 결과 동작은 문제없이 잘되는거 같은데…먼가 좀 찜찜하다는…
더 좋은 방법이 있을까요? ^^