Guest User

Untitled

a guest
Jun 23rd, 2018
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.03 KB | None | 0 0
  1. // sequelize config
  2.  
  3. var sequelize = new sequelize('database', 'user', 'pass', {
  4. host: '127.0.0.1',
  5. dialect: 'mysql',
  6. port: 3306,
  7. pool: {
  8. max: 10,
  9. min: 0,
  10. idle: 20000
  11. }
  12. });
  13.  
  14. // tunnel config
  15.  
  16. var config = {
  17. user:'user',
  18. host:'sshhost',
  19. port:22,
  20. dsthost:'127.0.0.1',
  21. dstport:3306,
  22. srchost:'127.0.0.1',
  23. srcport:3306,
  24. localhost:'127.0.0.1',
  25. localport: 3306,
  26. privatekey: require('fs').readfilesync('/path/to/key')
  27. };
  28.  
  29. var tunnel = require('tunnel-ssh');
  30. // initiate tunnel
  31.  
  32. tunnel(config, function (error, server) {
  33. //....
  34. if(error) {
  35. console.error(error);
  36. } else {
  37. console.log('server:', server);
  38. // test sequelize connection
  39. sequelize.authenticate().then(function(err) {
  40. console.log('connection established');
  41. }).catch(function(err) {
  42. console.error('unable establish connection', err);
  43. })
  44. }
  45. })
Add Comment
Please, Sign In to add comment