2

I'm trying to get a Crossbar.io app running on Heroku. Crossbar.io requires you to put the app's host in a config file that's used to launch the app. I've tried the following:

  1. my-app-name.herokuapp.com: No dice. I imagine Heroku does some fancy redirection internally that prevents this from working.
  2. $HOSTNAME: running a script that outputs the HOSTNAME and using the result in the config file doesn't work either. The HOSTNAME is a GUID that contains no useful information.
  3. IP: I tried getting the external IP of the app, but no luck. The IP changes each time I start the app.

Is there an established way to do this on Heroku?

Also the config requires a port and Heroku seems to assign these dynamically. Any way to access the port as well (ideally before the app runs)

4

1 回答 1

1

For the host use 0.0.0.0. For the port number it's slightly more complicated...

When it creates a web dynamo Heroku sets a PORT environment variable with the dynamo's port. To set this in crossbar you need to create a script that reads that variable and writes it into your config wherever the port is requested. Then you make sure that the script returns 0 on exit and put the following in your Procfile:

web: ./your_config_helper_script && crossbar start

That runs your script first (which should get your config file ready) before running crossbar

于 2014-12-27T09:46:56.733 回答