简体   繁体   中英

Running debug node_module on Openshift

I recently started using Openshift and it's been great so far. My current problem lies on the fact that my debug logs are not showing in Openshift's logs. I used to run the app locally with DEBUG=*,-express:* node ./bin/www and it showed everything I needed. So far I haven't figured how to translate this into the package.json file so that it works as intended.

package.json
{
  "name": "APP",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "start": "DEBUG=*,-express:* node ./bin/www"
  },
  "main": "./bin/www",
  "dependencies": { ... }

It seems to me that it is running the node command with the main data, instead of my much preferred script. I believe that the debug module is a great alternative to spamming console.log() on my code.

On the OpenShift log files it shows the following when starting the app. It is my understanding I am looking to find the --exec and change.

DEBUG: Running node-supervisor with
DEBUG:   program './bin/www'
DEBUG:   --watch '/var/lib/openshift/<app_ID>/app-root/data/.nodewatch'
DEBUG:   --ignore 'undefined'
DEBUG:   --extensions 'node|js|coffee'
DEBUG:   --exec 'node'
DEBUG: Starting child process with 'node ./bin/www'

If you look at the docs here and search for "markers", you'll find this:

use_npm:

Initialize your application or service using npm start instead of supervisor servername.js (where servername.js is based on the value of your package.json's main attribute).

I still think that it is better for you to use supervisor. But you can modify the value of debug within the code by having

process.env.DEBUG='*,-express:*';

before the first use of require("debug"), at least as a temporary solution.

HTH

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM