Guest User

Untitled

a guest
Oct 15th, 2018
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.15 KB | None | 0 0
  1. const OrientDBClient = require("orientjs").OrientDBClient;
  2. var _session, _client, _handle;
  3.  
  4. OrientDBClient.connect({
  5. host: "localhost",
  6. port: 2424
  7. }).then(client => {
  8. _client = client;
  9. client.session({ name: "YOURDB", username: "YOURID", password: "YOURPASSWORD" })
  10. .then(session => {
  11. // use the session
  12. console.log('session opened')
  13. _session = session;
  14. _handle = session.liveQuery("select from processcreate").on("data", data => {
  15. console.log(data);
  16. });
  17. })
  18. });
  19.  
  20. process.stdin.resume(); //so the program will not close instantly
  21. function exitHandler(err) {
  22. console.log('cleaning up...')
  23. _handle.unsubscribe()
  24. _session.close()
  25. .then(() =>{
  26. console.log('session closed');
  27. _client.close()
  28. .then(() => {
  29. console.log('client closed');
  30. process.exit();
  31. })
  32. })
  33.  
  34. }
  35.  
  36. process.on('exit', exitHandler.bind(null));
  37. process.on('SIGINT', exitHandler.bind(null));
  38. process.on('SIGUSR1', exitHandler.bind(null));
  39. process.on('SIGUSR2', exitHandler.bind(null));
  40. process.on('uncaughtException', exitHandler.bind(null));
Add Comment
Please, Sign In to add comment