0

I need to create an ssh tunnel to connect to my database, so the logical point would be to add the shell command in package.json under scripts/prestart.

However, as it seems, slc run does not execute this script, npm start does, but of course doesn't run the loopback module.

I could think of a few workarounds such as writing a startup script that both creates the ssh tunnel and calls slc run, or running slc run in package.json scripts/start, but all these workarounds stink.

Is there a better way to do this?

Svarog
  • 2,188
  • 15
  • 21
  • 1
    Why are you tying the ssh tunnel creation to the start of your app? On any app server where it's running wouldn't it be better to always have the tunnel open at boot via a simple setup script? Then it's an environment setup thing instead of an app config thing. The way strongloop apps are meant to be deployed in production with strong-pm also suggests moving db connectivity to an environment concern might make things easier down the road. – notbrain May 26 '15 at 20:17

1 Answers1

1

I'm not sure how useful this is but 1 option I thought of was that if you don't really make use of slc run features you could just define your own npm start run script and hit the server script directly and add in whatever other tooling you need such as nodemon or supervisor etc.:

"start": "node server/server.js"

If you do need to use slc run, I think I would tend toward just wrapping slc run in your start script as you mentioned in your question. It kinda stinks... but not that badly.

  • Yeah, wrapping slc run in my start script is what I eventually did. Don't think that's a good solution though :( – Svarog Nov 06 '15 at 11:32