永远运行一个Node.js Angular.js Gulp.js应用

Running a Node.js Angular.js Gulp.js application forever

本文关键字:js Node Angular Gulp 应用 一个 运行 永远      更新时间:2023-09-26

我正在研究一个Angular.js和Gulp.js web应用程序,并希望在Ubuntu 12.04环境中永久运行它。我安装了Angular &在这种环境下启动4仪表盘锅炉。它是作为构建工具随Gulp一起提供的。现在我想永久运行这个应用程序,以使客户/网站访问者可以访问它。我读了关于Gulp Forever和Gulp Forever Monitor的介绍,并安装了这些模块,但它们并没有奏效。应用程序总是在一段时间后关闭,我必须通过终端在环境中重新启动它。

那么,永远运行Gulp应用程序的最佳方式是什么呢?我要怎么做,我需要安装什么?由于我是新的,任何提示和建议将不胜感激,谢谢!

下面是gulpfile.js,其中包含了gulp server任务:

'use strict';
var gulp = require('gulp');
var wrench = require('wrench');
var forever = require('gulp-forever-monitor');
wrench.readdirSyncRecursive('./gulp').filter(function(file) {
  return (/'.(js)$/i).test(file);
}).map(function(file) {
  require('./gulp/' + file);
});
gulp.task('default', ['clean'], function () {
  gulp.start('build');
});
/*
gulp.task('run:server', function() {
    var foreverMonitorOptions = {
        env: process.env,
        args: process.argv,
        watch: true, // can pass if you set any watch option, for example watchIgnorePatterns
        watchIgnorePatterns:  ['.*', 'node_modules/**', 'public/**', 'temp/**']
    }
    forever('gulpfile.js', foreverMonitorOptions)
        .on('watch:restart', function(fileInfo) {
            console.log('server was restarted');
        })
        .on('exit', function() {
            console.log('server was closed');
        })
    gulp.start('build');
})
*/

您可以尝试使用plain Forever。