Using Variables in a Heroku Procfile
A Heroku Procfile has access to the config variables set for an app. This can be used to make the Procfile dynamic.
In Heroku, an app’s config variables can be set in two ways.
1.) Using the web interface to navigate to the app’s settings tab:
2.) With the following command:
heroku config:set CONFIG_VAR_NAME=var_value -a appName
These variables can now be access by prefixing the variable name with $. This can be useful in a few ways. For instance, let’s say that we want to dynamically set the heap size of a web server dynamically. We could first create a HEAP_SIZE configuration variable and then access it in the Procfile.
web: node --max_old_space_size=$HEAP_SIZE server.js
To learn more about a Procfile, visit https://devcenter.heroku.com/articles/procfile
By default, Node sets a memory/heap size limit that is under 2 GB. This default can be changed by passing in a value in megabytes (MB) when starting a Node server using the following option:
Thus, the command below will start a server with a heap size of up to 4 GB.
node --max_old_space_size=4000 scriptThatStartsServer.js
You can take advantage of one of the best features of TypeScript — smart code completion (IntelliSense) for modules and packages while using Visual Studio Code (VSC) — without needing to use it in a project.
a. Install TypeScript globally
$ npm install -g typescript
b. Install Typings globally
$ npm install -g typings
Note: run the command below from the root of your project. …