Tutorial: Adding and Running an Executable to the Server

Adding and Running an Executable to the Server

Tutorial

Adding and running an executable to the backend

  1. Add a route to index.js to handle a call.
  2. An example of this is router.get('/vasp', function(req, res, next) {…}
  3. '/vasp' is the name of the call from the frontend – this can be called anything.
  4. Create a child that holds the executable call.
  5. Use const child = spawn(…) 1. Use 'executables' path for the last parameter of spawn() to point to the correct path for executables.
  6. Must add child.on('error') to avoid errors.
  7. Can also add child.on('close'), child.stdout.on(), child.stderr.on() for debugging.
  8. In /views folder, add a reference to the route call from above.
  9. For example, if route call is '/vasp', then form(action='/vasp' method ='POST')
  10. Add your executable files to /executables
  11. The call to the executable will be exactly what your call is from the terminal. This would be the easiest way to run the executable. For example,
constchild = spawn('python', ['./DiffBond\_v2.py', '-i', '../public/uploads/1brs.pdb', '-m', 'i'], executables)