0

I know that OpenShift has a cron cartridge which we can use to perform tasks such as clean ups, run backups,...

In my case my Node.js application is a worker and on each run it updates my databases based on external resources.

My plan was to use OpenShift cron to run the main entry point of my application on every job run, e.g. running following command :

node databaseUpdater.js

I found another SO question and answer on how to exec a Node.js, but my issue is that I don't know what is the full path of OpenShift's node, or even if they would allow me to do such thing?

I tried using node databaseUpdater.js and hoping to be lucky and OpenShift automagically run my app, but I was wrong!

Any help how to get the full path to node or any better way to overcome this issue on OpenShift?

Community
  • 1
  • 1
Amir
  • 9,577
  • 11
  • 41
  • 58

2 Answers2

1

The node is on the openshift visible globally. So that you can call it from the cron folder. Then just add your script name by a variable that includes the deployment folder:

node ${OPENSHIFT_REPO_DIR}/cron.js

Check all variables: https://developers.openshift.com/managing-your-applications/environment-variables.html#directory-variables

Tomas Randus
  • 2,127
  • 4
  • 29
  • 38
0

You can determine where the node executable is located, because you can ssh into your OpenShift application by doing

rhc ssh <app-name>

And once in that shell you can ask where the node.js executable is located by doing a

which node

And it'll tell you where to find it. I wonder however, if the node executable is already available in the path of your crone job. If so, maybe you can simply invoke node directly.

Have you tried that?

Edwin Dalorzo
  • 76,803
  • 25
  • 144
  • 205