node.js - Loopback3 calling remote method or API periodically -


basically, requirement keep looking new files in folder, read contents of file , call loopback api.

to achieve trying below:

i have remote method in loopback needs called periodically i.e. after every 2 minutes. read asynchronous boot scripts in official loopback documentation here: https://loopback.io/doc/en/lb2/defining-boot-scripts#synchronous-and-asynchronous-boot-scripts far have been able write following code:

module.exports = function(app, callback) {   setinterval(function() {     console.log('hello world');     callback();   }, 120000); }; 

but throws error below.

error: uncaughtexception: listen eaddrinuse :::443 

also, there way call remote methods bootscripts ? loopback support cron/schedular or polling functionality. need write separate nodejs application call api periodically.

thanks

your error states address(port number) if server in use.

error: uncaughtexception: listen eaddrinuse :::443

  1. you can try listen on other port number

    app.listen(3000, function() { console.log('listening on 3000') });

  2. kill process running on same port

first, want know process using port 3000

sudo lsof -i :3000 

this list pid listening on port, once have pid can terminate following:

kill -9 {pid} 
  1. check if code not calling multiple listen on same port

let me know if isn't resolving problem


Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -