{"action":"created","issue":{"url":"https://api.github.com/repos/lambduh/lambduh-execute/issues/2","repository_url":"https://api.github.com/repos/lambduh/lambduh-execute","labels_url":"https://api.github.com/repos/lambduh/lambduh-execute/issues/2/labels{/name}","comments_url":"https://api.github.com/repos/lambduh/lambduh-execute/issues/2/comments","events_url":"https://api.github.com/repos/lambduh/lambduh-execute/issues/2/events","html_url":"https://github.com/lambduh/lambduh-execute/issues/2","id":160415858,"number":2,"title":"About tasks folder and executable files","user":{"login":"loretoparisi","id":163333,"avatar_url":"https://avatars.githubusercontent.com/u/163333?v=3","gravatar_id":"","url":"https://api.github.com/users/loretoparisi","html_url":"https://github.com/loretoparisi","followers_url":"https://api.github.com/users/loretoparisi/followers","following_url":"https://api.github.com/users/loretoparisi/following{/other_user}","gists_url":"https://api.github.com/users/loretoparisi/gists{/gist_id}","starred_url":"https://api.github.com/users/loretoparisi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/loretoparisi/subscriptions","organizations_url":"https://api.github.com/users/loretoparisi/orgs","repos_url":"https://api.github.com/users/loretoparisi/repos","events_url":"https://api.github.com/users/loretoparisi/events{/privacy}","received_events_url":"https://api.github.com/users/loretoparisi/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":6,"created_at":"2016-06-15T12:59:38Z","updated_at":"2016-07-10T15:19:48Z","closed_at":null,"body":"I don't get this code\r\n\r\n```javascript\r\n.then(function(result) {\r\n    return execute(result, {\r\n      shell: \"cp /var/task/ffmpeg /tmp/.; chmod 755 /tmp/ffmpeg\", // copies an ffmpeg binary to /tmp/ and chmods permissions to run it\r\n      logOutput: true\r\n    })\r\n  })\r\n```\r\n\r\nIs that means that the executable `must be` in the `/var/task` folder or they can be in a arbitrary folder? \r\nWhen I upload my zip file (via S3) to Lambda the executable are at the same level of the `index.js` like\r\n\r\n```\r\nmacbookproloreto:src admin$ tree -L 1\r\n.\r\n├── config.js\r\n├── ffmpeg\r\n├── ffprobe\r\n├── gulpfile.js\r\n├── index.js\r\n└── lambdaapihelper.js\r\n```\r\n\r\nSo in this case can I do like\r\n\r\n```javascript\r\n.then(function(result) {\r\n    return execute(result, {\r\n      shell: \"cp ./ffmpeg /tmp/.; chmod 755 /tmp/ffmpeg\", // copies an ffmpeg binary to /tmp/ and chmods permissions to run it\r\n      logOutput: true\r\n    })\r\n  })\r\n```\r\n\r\nand I get as logging\r\n\r\n```shell\r\n2016-06-15T13:02:26.119Z\t685476e8-32f9-11e6-b004-e5e236444b4c\texec stdout: ffmpeg fp_a8dba864e1571d39e786389317e5619a_1.mp4  \r\n2016-06-15T13:02:26.120Z\t685476e8-32f9-11e6-b004-e5e236444b4c\texec stderr:  \r\n2016-06-15T13:02:26.120Z\t685476e8-32f9-11e6-b004-e5e236444b4c\tspawning shell \r\n2016-06-15T13:02:26.120Z\t685476e8-32f9-11e6-b004-e5e236444b4c\t{ shell: 'cp /var/task/ffmpeg /tmp/.; chmod 755 /tmp/ffmpeg', logOutput: true }\r\n```\r\n\r\nIs that correct? This brings me to the second question about logging, where is logging output going? I can see in CloudWatch\r\n\r\n```console\r\nSTART RequestId: 64aec75d-32f9-11e6-889b-6381565ec002 Version: $LATEST \r\n2016-06-15T13:02:21.821Z\t64aec75d-32f9-11e6-889b-6381565ec002\tspawning shell \r\n2016-06-15T13:02:21.822Z\t64aec75d-32f9-11e6-889b-6381565ec002\t{ shell: 'echo `ls /tmp/`', logOutput: true }\r\n2016-06-15T13:02:26.981Z\t685476e8-32f9-11e6-b004-e5e236444b4c\texec stdout:  \r\n2016-06-15T13:02:26.981Z\t685476e8-32f9-11e6-b004-e5e236444b4c\texec stderr: \r\n```\r\n\r\nbut not the commands output logged for the `ls`.\r\n\r\nLatest but not least question, as soon as I configure the executable (hopefully ok) I call this function\r\n\r\n```javascript\r\nMediaHelper.prototype.probe = function(fpath) {\r\n      var self=this;\r\n      return new Promise((resolve, reject) => {\r\n    \t\tconst args = [\r\n    \t\t\t'-v', 'quiet',\r\n    \t\t\t'-print_format', 'json',\r\n    \t\t\t'-show_format',\r\n          '-show_streams',\r\n    \t\t\t'-i', fpath\r\n    \t\t];\r\n    \t\tconst opts = {\r\n    \t\t\tcwd: self._options.tempDir\r\n    \t\t};\r\n    \t\tconst cb = (error, stdout) => {\r\n    \t\t\tif (error)\r\n    \t\t\t\treturn reject(error);\r\n          try {\r\n            const outputObj = JSON.parse(stdout);\r\n            return resolve( outputObj );\r\n          } catch(ex) {\r\n              return reject(ex);\r\n          }\r\n        };\r\n        cp.execFile('ffprobe', args, opts, cb)\r\n    \t\t\t.on('error', reject);\r\n    \t});\r\n    }//probe\r\n```\r\n\r\nand this one for `ffmpeg`\r\n\r\n```javascript\r\nMediaHelper.prototype.cut = function(fpath,opath,duration,start) {\r\n      var self=this;\r\n\r\n      // defaults\r\n      start = start || '00:00:00';//start 0\r\n      duration = duration || self._options.maxDuration+''; //default to maxDuration\r\n\r\n      return new Promise((resolve, reject) => {\r\n    \t\tconst args = [\r\n          '-y',\r\n    \t\t\t'-loglevel', 'warning',\r\n    \t\t\t'-i', fpath,\r\n          '-ss', start,\r\n          '-t', duration,\r\n          '-async', '1',\r\n          opath\r\n    \t\t];\r\n    \t\tconst opts = {\r\n    \t\t\tcwd: self._options.tempDir\r\n    \t\t};\r\n        cp.spawn('ffmpeg', args, opts)\r\n    \t\t\t.on('message', msg => self.logger.info(msg))\r\n    \t\t\t.on('error', reject)\r\n    \t\t\t.on('close', resolve);\r\n    \t});\r\n    }//cut\r\n```\r\n\r\nwhat I get is this then\r\n\r\n```shell\r\n2016-06-15T13:02:26.119Z\t685476e8-32f9-11e6-b004-e5e236444b4c\texec stdout: ffmpeg fp_a8dba864e1571d39e786389317e5619a_1.mp4  \r\n2016-06-15T13:02:26.120Z\t685476e8-32f9-11e6-b004-e5e236444b4c\texec stderr: \r\n```\r\n\r\nDoes this mean that the executable was not found? While the lines does not show exec arguments I have passed to `cp.execFile`? \r\n\r\nThank you.\r\n"},"comment":{"url":"https://api.github.com/repos/lambduh/lambduh-execute/issues/comments/231594278","html_url":"https://github.com/lambduh/lambduh-execute/issues/2#issuecomment-231594278","issue_url":"https://api.github.com/repos/lambduh/lambduh-execute/issues/2","id":231594278,"user":{"login":"loretoparisi","id":163333,"avatar_url":"https://avatars.githubusercontent.com/u/163333?v=3","gravatar_id":"","url":"https://api.github.com/users/loretoparisi","html_url":"https://github.com/loretoparisi","followers_url":"https://api.github.com/users/loretoparisi/followers","following_url":"https://api.github.com/users/loretoparisi/following{/other_user}","gists_url":"https://api.github.com/users/loretoparisi/gists{/gist_id}","starred_url":"https://api.github.com/users/loretoparisi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/loretoparisi/subscriptions","organizations_url":"https://api.github.com/users/loretoparisi/orgs","repos_url":"https://api.github.com/users/loretoparisi/repos","events_url":"https://api.github.com/users/loretoparisi/events{/privacy}","received_events_url":"https://api.github.com/users/loretoparisi/received_events","type":"User","site_admin":false},"created_at":"2016-07-10T15:19:48Z","updated_at":"2016-07-10T15:19:48Z","body":"Hi @russmatney, so at the end I realized that, since recents lambda OS udpates, there is not need anymore to `cp` binaries elsewhere. This now is simply as copying `ffmpeg` and `ffprobe` binaries in the `dist/` folder (or wherever you prefer) that you are going to distribute to lambda backend. Before that, just `chmod 755 ./ff*`, that was we were doing on lambda before so I made this optional\r\n\r\n\r\n```javascript\r\nif(self._options.copyBinaries)\r\n        {\r\n          var result = {}\r\n          execute(result, {\r\n            shell: \"cp ./ffmpeg /tmp/.; chmod 755 /tmp/ffmpeg\", // copies an ffmpeg binary to /tmp/ and chmods permissions to run it\r\n            logOutput: true\r\n          })\r\n          .then(function(result) {\r\n            return execute(result, {\r\n               shell: \"cp ./ffprobe /tmp/.; chmod 755 /tmp/ffprobe\", // copies an ffmpeg binary to /tmp/ and chmods permissions to run it\r\n               logOutput: true\r\n             })\r\n          })\r\n          .then(function(result) {\r\n             self.logger.info(\"LambdaAPIHelper.Configure done.\");\r\n          })\r\n          .fail(function(err) {\r\n            self.logger.error(\"LambdaAPIHelper.Configure: error %s\",err);\r\n          });\r\n        } //copyBinaries\r\n```\r\nbut having `self._options.copyBinaries=false` since so far it does work without this copy phase.\r\nSo, at the end, in the lambda I just have the same tree in my `LAMBDA_TASK_ROOT` folder:\r\n\r\n```shell\r\n├── config.js\r\n├── ffmpeg\r\n├── ffprobe\r\n├── index.js\r\n└── lambdaapihelper.js\r\n```\r\n\r\nand I just execute those binaries using as path `./` with the same scripts I pasted here for the `MediaHelper` class.\r\n\r\nThank you, and if you make a wiki for logging question, etc. this would help as well!\r\n\r\n"}}
{"actor":{"display_login":"loretoparisi"}}