Skip to content

Instantly share code, notes, and snippets.

@yang-wei
Last active June 24, 2016 14:07
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save yang-wei/3dadb855e84bebd2ab8a to your computer and use it in GitHub Desktop.
Save yang-wei/3dadb855e84bebd2ab8a to your computer and use it in GitHub Desktop.
Open shift npm start

##Openshift pitfall during deployment

###MongoDB address

###Marker Files By default, openshift will start our nodejs application by running supervisor server.js. However we might want to do more(like testing, transform) any changed file when starting our application. For example, our scripts field in package.json looks like this.

"scripts": {
    ...
    "build": "browserify -t reactify client/client.js -o public/bundle.js",
    "server": "supervisor server/server.js",
    "start": "npm run build && npm run server"
},

Everytime before we start our server, we want browserify to do something first by running npm start. To do this we can use marker file. By adding an empty files named use_npm in our .openshift/markers directory, our app will start by runnning npm start. If we do not have .openshift directory yet, create one.

mkdir -p .openshift/markers
cd .openshift/markers
touch use_npm

Usually some comments is added inside use_npm file for clarification.

#!/bin/bash
# include this file to make sure it starts by npm start

###Resource

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment