I'm trying to run the following script in a Laravel controller:
public function importLinkedin(Request $request)
{
$process = new Process("node node/test.js");
$process->run();
if (!$process->isSuccessful()) {
throw new ProcessFailedException($process);
}
echo $process->getOutput();
}
If I run the following command from terminal I get the expected output
node /var/www/website/public/node/test.js
When running the script from the Laravel controller the browser doesn't stop loading until it times out. (504 Gateway Time-out)
test.js file looks like this
const scrapedin = require('/usr/local/lib/node_modules/scrapedin')
const fs = require('fs')
const cookies = fs.readFileSync('/usr/cookies.json')
const options = {
cookies: JSON.parse(cookies)
}
scrapedin(options)
.then((profileScraper) => profileScraper('https://www.linkedin.com/in/profile-url/'))
.then((profile) => console.log(profile))