1

i used yo generator to install a skeleton mean js program with a grunt build to do the minifications and deployment.

What is the steps to be taken to deploy with pm2?

Right now im using nodemon to keep my app alive and im using digitalocean console stream to run the following command:

NODE_ENV=production PORT:80 grunt --force

That does according to my gruntfile the following:

    concurrent: {
        default: ['nodemon', 'watch'],
        options: {
            logConcurrentOutput: true
        }
    },

....

nodemon: {
            dev: {
                script: 'server.js',
                options: {
                    //nodeArgs: ['--debug'],
                    ext: 'js,html',
                    watch: watchFiles.serverViews.concat(watchFiles.serverJS)
                }
            }
        },

grunt.registerTask('default', ['sass','lint', 'concurrent:default']);

What configuration should i add/change in my gruntfile to make all of this work with pm2? ( I need it for clustering and load-balance my app ).

totothegreat
  • 1,633
  • 4
  • 27
  • 59
  • 1
    possible duplicate http://stackoverflow.com/questions/25007130/how-to-use-grunt-gulp-with-pm2 – Robbie Sep 05 '15 at 20:33
  • 1
    It is still unclear to me how and what to configure in my gruntfile for this to work. – totothegreat Sep 05 '15 at 21:22
  • I think the best approach would be to build a version of your sw for production and then in pm2 run the built version of `app.js`. – morels Feb 22 '17 at 13:39

1 Answers1

1

On the command line do:

$ export NODE_ENV=production

will setup production environmental

$ grunt build

will create necessary .min.js and min.css

$ pm2 start server.js

will load the server with pm2, that its a package thats makes sure the node server will restart if an error and will log.

Keyur Potdar
  • 7,158
  • 6
  • 25
  • 40
Prem Sanil
  • 128
  • 8