SCE-Development / Quasar

How paper is printed at SCE.
MIT License
4 stars 0 forks source link

Add function to ping peripheral before sending request #22

Open evanugarte opened 2 years ago

evanugarte commented 2 years ago

When Quasar is running in production, we assume the printer(s)/LED sign is at a certain IP address and forward requests to it, no questions asked. This risks having a request be forwarded to a non existent device and then the SQS message deleted meaning we cannot recover the failed request.

The ping command can be used to check if a device is up at a certain IP address. To run the ping command from Node, we can use exec. An example is below:

const { exec } = require('child_process');

exec('ping <ip address>', function(error, stdout, stderr) {
  // do something with error, stdout, stderr
});

If you're unfamiliar with ping, check out this animated YouTube video.

Some things to consider

Ideal workflow

evanugarte commented 5 months ago

pinging the printer should happen before Quasar replies to Clark from the print request. if the printer is down, return 500 to Clark.

game plan

game plan (clark)