I have a NodeJS app that runs as a process and that executes a task every 15 minutes using node-schedule
.
We first need a manifest.yml file that contains:
--- applications: - name: APP-NAME buildpack: nodejs_buildpack no-route: true health-check-type: process env: OPTIMIZE_MEMORY: true
The no-route
parameter is true so that we don’t get a route assigned, and the health-check-type
is set to process so that the orchestrator monitors process availability and doesn’t try to ping a non-existent web endpoint. And OPTIMIZE_MEMORY
in « env » section is based on the Pivotal recommendations.
If you need to use a local package in your app, you’ll have to pack it up first. To do it, go to your local module folder, and type npm pack
. It will create a .tgz
file that you’ll have to store in a local_modules folder for your app. Next, in the package.json of the app, you’ll put the below in the dependencies section:
{ "name": "APP-NAME", "version": "1.0.0", "scripts": { "start": "node index.js" }, "dependencies": { "my-module": "file:./local_modules/my-module-7.0.0.tgz" } }
You can now deploy your app with pcf push APP-NAME
and you can read the logs with cf logs APP-NAME --recent
.