npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

gulp-develop-server-reuse

v0.5.4

Published

运行node.js服务,可自动重启. fork from https://github.com/narirou/gulp-develop-server.git

Downloads

9

Readme

gulp-develop-server-reuse-reuse

fork from https://github.com/narirou/gulp-develop-server.git

run your node.js server and automatically restart with gulp.

Build Status Dependency Status Test Coverage Npm Modules MIT Licensed

gulp-develop-server-reuse is a development assistant for node.js server that runs the process and automatically restarts it when a file is modified.

installation

npm install gulp-develop-server-reuse --save-dev

usage

var gulp   = require( 'gulp' ),
    GulpServer = require( 'gulp-develop-server-reuse' );
var server = new GulpServer();

// run server
gulp.task( 'server:start', function() {
    server.listen( { path: './app.js' } );
});

// restart server if app.js changed
gulp.task( 'server:restart', function() {
    gulp.watch( [ './app.js' ], server.restart );
});

api

###server.listen( options[, callback] )

options {Object}

  • path

    • type: {String}
    • example: './your_node_app.js'
    • Your node application path. This option is required.
  • env

    • type: {Object}
    • default: { NODE_ENV: 'development' } (extends current process.env)
    • example: { PORT: 3000, NODE_ENV: 'production' }
    • Environment settings of your server.
  • args

    • type: {Array}
    • your application's arguments
  • execArgv

    • type: {Array}
    • example: [ '--harmony' ]
    • Run node process with this options.
  • delay

    • type: {Number}
    • default: 600
    • If this plugin does not receive an error from the server after options.delay seconds, assumes the server listening success.
    • This option needs to adjust according to your application's initialize time.
    • If this option set 0, it will only check successMessage.
  • successMessage

    • type: {RegExp}
    • default: /^[Ss]erver listening/
    • If your application send the specific message by process.send method, this plugin assumes the server listening success.
  • errorMessage

    • type: {RegExp}
    • default: /[Ee]rror:/
    • If this plugin receives the specific error message that matched this RegExp at start-up, assumes the server has error.
  • killSignal

    • type: {String}
    • default: SIGTERM

callback( error )

###server.restart( [callback] ) / server.changed( [callback] )

callback( error )

###server( [options] )

Create a Transform stream. Restart the server at once when this stream gets files.

###server.kill( [signal, callback] )

Send kill signal to the server process.
signal {String}
callback( error )

###server.reset( [signal, callback] )

Send kill signal to the server process and reset the options to default.
signal {String}
callback( error )

more examples

####with gulp-livereload:

var gulp       = require( 'gulp' ),
    GulpServer     = require( 'gulp-develop-server-reuse' ),
    livereload = require( 'gulp-livereload' );
var server = new GulpServer();
var options = {
    path: './apps/app.js'
};

var serverFiles = [
    './apps/app.js',
    './routes/*.js'
];

gulp.task( 'server:start', function() {
    server.listen( options, livereload.listen );
});

// If server scripts change, restart the server and then livereload.
gulp.task( 'default', [ 'server:start' ], function() {
    
    function restart( file ) {
        server.changed( function( error ) {
            if( ! error ) livereload.changed( file.path );
        });
    }

    gulp.watch( serverFiles ).on( 'change', restart );
});

####with BrowserSync:

var gulp   = require( 'gulp' ),
    GulpServer = require( 'gulp-develop-server-reuse' ),
    bs     = require( 'browser-sync' );
var server = new GulpServer();
var options = {
    server: {
        path: './apps/app.js',
        execArgv: [ '--harmony' ]
    },
    bs: {
        proxy: 'http://localhost:3000'
    }
};

var serverFiles = [
    './apps/app.js',
    './routes/*.js'
];

gulp.task( 'server:start', function() {
    server.listen( options.server, function( error ) {
        if( ! error ) bs( options.bs );
    });
});

// If server scripts change, restart the server and then browser-reload.
gulp.task( 'server:restart', function() {
    server.restart( function( error ) {
        if( ! error ) bs.reload();
    });
});

gulp.task( 'default', [ 'server:start' ], function() {
    gulp.watch( serverFiles, [ 'server:restart' ] )
});

####use as a stream:

var gulp   = require( 'gulp' ),
    GulpServer = require( 'gulp-develop-server-reuse' ),
    bs     = require( 'browser-sync' ),
    coffee = require( 'gulp-coffee' );
var server = new GulpServer();
var options = {
    server: {
        path: './apps/app.js',
        execArgv: [ '--harmony' ]
    },
    bs: {
        proxy: 'http://localhost:3000'
    }
};

var serverCoffee = [
    './src/*.coffee'
];

gulp.task( 'server:start', function() {
    server.listen( options.server, function( error ) {
        if( ! error ) bs( options.bs );
    });
});

// If server side's coffee files change, compile these files,
// restart the server and then browser-reload.
gulp.task( 'server:restart', function() {
    gulp.src( serverCoffee )
        .pipe( coffee() )
        .pipe( gulp.dest( './apps' ) )
        .pipe( server.stream() )
        .pipe( bs.reload({ stream: true }) );
});

gulp.task( 'default', [ 'server:start' ], function() {
    gulp.watch( serverCoffee, [ 'server:restart' ] );
});

thanks

@pronebird
@vkareh
@chimerast
@silverbp
@tomxtobin