Running NodeBB on AppFog

General Discussion
  • I just wanted to tell you I decided to try running NodeBB on a free PaaS (Platform as a Service) or other trendy cloud hosting.

    After some research I settled with rather than Heroku, since I can start testing without providing my credit card number, but I must say I hit a wall. A couple of walls to be more precise. But I'm a [redacted] juggernaut [redacted] and I had too much free time so I managed to break through all of them. I'm making this topic in hope I save time for other people like me and I hope to suggest some improvements to the dev team.

    In short, there were two problems:

    • dynamic redis configuration
    • need for setup before starting the app

    Dynamic Redis Config

    In appfog, when you request and bind a redis service to your app, you don't get a globally accessible address, nor user/password for the service. It is (somehow) generated dynamically and provided in an environment variable for your app. Therefore I couldn't just put it in the config.json file - I didn't know it before actually starting the app. I could of course hack and dump the environment variable onto an html page, write it down, put it in config, reupload app and hope it doesn't change any time soon. But instead I had to add some little magic javascript file that was run during app initialization, that would read those funky appfog ENV and copy them to proper NodeBB options (redis host, port and password). I'm not saying this is NodeBB's fault (nor it is AppFog's fault) but sometimes app configuration isn't as easy as a developer thinks - especially if you work in an environment you can't just SSH to.

    Need for setup

    As established before, since I'm hosting my nodebb app in an unknown faraway place, with no ability to SSH in and no way to connect directly to my redis (it's behind a firewall or smth), the fact that nodebb requires me to run "node app --setup" is very problematic. Since I couldn't find anything about making an automatic installation in any docs/github, I reverse engineered the setup code to find one can actually skip interactive setup by providing proper (albeit quite complicated) environment variables or command line options. Since I can run my appfog app with custom environment vars it wouldn't be a problem, until I found out I had to read the dynamic redis config described above before I could fill in all the fields - I just integrated all of it into one hacky javascript file (reading options, reding ENV, adding some options, etc.) and run the application twice (first time to populate the redis, second time without the setup options).


    Although it wasn't easy I'm very satisfied with nodebb, devs are doing a great job and I hope they keep it up. All that's left for me is to go to appfog forums/support and rant about them not supporting websockets!

  • @Szymon-Maj Nice job!

    We ran into issues like this before, even with Heroku. Heroku assigns a dynamic port to their apps as well, so we're looking into reading certain environment variables instead of relying on one provided in a setup config file. The real problem here is that all of them use different environment variables (boooo!)

    Secondly, you can call --setup="{aJSONString}", and that'll fill in the setup information for you 🙂


Suggested Topics