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

grunt-node-auto-deploy

v1.0.2

Published

Automatic deployment of node apps via grunt to nginx-upstart server.

Downloads

4

Readme

grunt-node-auto-deploy

Automatic deployment of your node apps via grunt to ubuntu server using nginx and upstart.

About

The task connects to your server via SSH (via ssh key only) and writes nginx configuration files. Your app starts on boot a runs as a service via pm2. Application is cloned from it's remote git repository. When the app is cloned, task runs npm install together with optional commands like grunt tasks to build distribution files. Then it reloads nginx.

Dependencies

This grunt task requires you to have linux server (ubuntu 16 tested) running nginx, nodejs, npm, and git.

Issues

Please report all issues you may find. Do it preferably at https://github.com/petrkrulis/grunt-node-auto-deploy/issues. It'll be very helpful.

Changelog

1.0.2

  • empty aliases fix

1.0.1

  • almost zero downtime (fetch & install in temporary folder)
  • dont obtain SSL certificates every time (only when they are not present)

1.0.0

  • now using pm2 instead upstart
  • custom nginx conf file
  • able to obtain letsencrypt certs
  • able to use only static web (no node app)

0.6.4

  • fixed start/stop application in apps subfolder

0.6.3

  • updated dependencies (mainly grunt 1.x.x)

0.6.2

  • /etc/init scripts are saved to the /etc/init/apps subfolder

0.6.1

  • Fixed fatal bug

0.6.0

  • Conf property
  • Alias is now a redirect instead of standalone server

0.5.8

  • Properly close SSH connection after deployment

0.5.5

  • Removed unwanted console output

0.5.4

  • Added support for domain alias (so you can add www subdomain easily)
  • Fixed optional commands order

Getting Started

This plugin requires Grunt >=0.4.5

If you haven't used Grunt before, be sure to check out the Getting Started guide, as it explains how to create a Gruntfile as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command:

npm install grunt-node-auto-deploy --save-dev

Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:

grunt.loadNpmTasks('grunt-node-auto-deploy');

The "node_auto_deploy" task

Overview

In your project's Gruntfile, add a section named node_auto_deploy to the data object passed into grunt.initConfig().

grunt.initConfig({
  node_auto_deploy: {
    options: {
      url: 'petrkrulis.cz',
      alias: ['www.petrkrulis.cz', 'alias.petrkrulis.cz'], // can be string or array
      getSSLCerts: true, (will call 'letsencrypt certonly -a webroot --agree-tos --renew-by-default --webroot-path=/var/www/html -d domain')
      conf: true, // set to false to not upload nginx conf file
      useNode: settings.useNode, // use statis web or nginx proxy to node app
      command: 'node server.js', // discontinued
      index: 'server.js' // nodejs app index
      name: 'petrkrulis-web', // pm2 app name
      port: '8081',
      path: '/var/www/sites',
      nginx: '/etc/nginx/sites-enabled',
      nginxConf: 'nginx.conf' // nginx custom conf file to use
      git: 'git://github.com/petrkrulis.cz/grunt-node-auto-deploy.git',
      branch: 'master',
      ssh: '[email protected]',
      before: [
        'echo hello'
      ],
      then: [
        'grunt build'
      ]
    }
  },
});

Options

options.url

Type: String

The URL of your app. If you don't own a domain name yet, just pass example.com to it and add that domain to your hosts file. You can test the app from the browser then.

options.alias

Type: String or Array (optional)

Alias is optional. Use it to redirect for example a www subdomain to your app.

options.conf

Type: Boolean (optional)

Whether to upload ngnix configuration files. Default value is true (will be uploaded). If you need to manage conf files by yourself, let the plugin know not to upload them.

options.command

Type: String

Command used to start the app. Mostly it'll be something like 'node app.js' but you can use anything you need.

options.port

Type: String

NodeJS application port (where the server is listening for connections).

options.path

Type: String

Absolute path to the app. This task takes the options.path path, creates a folder named by the options.url in it and clone the git repository specified in options.git.

options.nginx

Type: String

Path to ngnix sites-enabled folder. Or basicaly any folder where nginx automatically load all conf files and use them in it's configuration.

options.git

Type: String

Git repository to clone. It should contain the app you want to run :)

options.branch

Type: String

The branch which will be cloned from the git repository.

options.ssh

Type: String

SSH server adress. Use ssh key to login instead of password. I decided not to add support for password access. It's insecure and slow and you would need to type itevery time (you don't want to store the password in a gruntfile).

options.before

Type: Array (optional)

It's an optional array of commands executed before anything else. All commands in options.before & options.then are executed from application path (the app's root where package.json is stored).

options.then

Type: Array (optional)

It's an optional array of commands executed after successful deploy and npm install and before start command. Useful as hell if you dont want to include distribution files to git repository. You can easily build them on server, just include all necessary packages in dependecies (not only in devDependencies - this runs in production environment).

Contributing

In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using Grunt.