简体   繁体   English

如何通过mean.js设置在grunt中使用pm2?

[英]How to use pm2 in grunt with a mean.js setup?

i used yo generator to install a skeleton mean js program with a grunt build to do the minifications and deployment. 我用yo generator安装了一个粗略的js框架,以实现最小化和部署。

What is the steps to be taken to deploy with pm2? 使用pm2部署应采取什么步骤?

Right now im using nodemon to keep my app alive and im using digitalocean console stream to run the following command: 现在,我使用nodemon使我的应用程序保持活动状态,并且我使用digitalocean控制台流来运行以下命令:

NODE_ENV=production PORT:80 grunt --force

That does according to my gruntfile the following: 根据我的gruntfile,这确实做到了以下几点:

    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? 我应该在gruntfile中添加/更改什么配置以使所有这些与pm2一起使用? ( I need it for clustering and load-balance my app ). (我需要它来集群和负载均衡我的应用程序)。

On the command line do: 在命令行上执行:

$ export NODE_ENV=production

will setup production environmental 将建立生产环境

$ grunt build

will create necessary .min.js and min.css 将创建必要的.min.js和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. 将使用pm2加载服务器,其软件包可确保节点服务器在发生错误时重新启动并记录日志。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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