0

Earlier in OpenShift Node.js app the process.env.OPENSHIFT_REPO_DIR environment variable was available. No I migrated to OpenShift 3, and I get error.

var apn = require('apn');
var optionsP = {
    token: {
        key: process.env.OPENSHIFT_REPO_DIR + 'APNsAuthKey_AQ34EHZCDQ.p8',
        keyId: "AQ34EHZCDQ",
        teamId: "AQUJ3H44A4",
    },
    production: true,
};

var apnProviderP = new apn.Provider(optionsP);

/opt/app-root/src/node_modules/apn/lib/credentials/token/prepare.js:15
      throw new VError(err, "Failed loading token key");
      ^
VError: Failed loading token key: ENOENT: no such file or directory, open 'undefinedAPNsAuthKey_AQ34EHZCDQ.p8'
    at prepareToken (/opt/app-root/src/node_modules/apn/lib/credentials/token/prepare.js:15:13)
    at config (/opt/app-root/src/node_modules/apn/lib/config.js:42:31)
    at new Client (/opt/app-root/src/node_modules/apn/lib/client.js:11:19)
    at EventEmitter.Provider (/opt/app-root/src/node_modules/apn/lib/provider.js:12:19)
    at Object.<anonymous> (/opt/app-root/src/server.js:26:20)
    at Module._compile (module.js:570:32)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)

Any idea?

János
  • 32,867
  • 38
  • 193
  • 353

1 Answers1

1

Under OpenShift 3, if using the bundled S2I builders for different languages, in most cases your application source code will reside at the directory /opt/app-root/src. There is no environment variable specifying what the directory is.

To confirm what the directory is, you can use oc rsh to get an interactive shell in the container for your application and then run pwd. Normally the default directory is where your application code is.

Graham Dumpleton
  • 57,726
  • 6
  • 119
  • 134
  • Fine, corrected, but seems `OpenShift` does not fetch source, do you have any idea? https://stackoverflow.com/questions/46136375/why-openshift-gear-use-so-much-space – János Sep 27 '17 at 08:57
  • What about `process.env.OPENSHIFT_NODEJS_PORT`, `process.env.OPENSHIFT_NODEJS_IP`, are these environment variables available? – János Sep 27 '17 at 08:59
  • No. If ``OPENSHIFT_NODEJS_PORT`` is not set, fallback to using port 8080. If ``OPENSHIFT_NODEJS_IP`` is not set, fallback to using ``0.0.0.0``. – Graham Dumpleton Sep 27 '17 at 09:20