pierrot

0.0.0-beta.1 • Public • Published

Pierrot NPM version Build Status Coverage Status

pm2 virtual-host and deploy cli

Installation

$ npm install pm2 bouncy pierrot --global

Define pierrot.yml

Can use $ sudo pierrot vhost if define one or more apps in ./pierrot.yml.

apps:
  homepage:
    repo: https://github.com/59naga/berabou.me.git
    from: 59naga.localhost
    to: 59798

Start the virtual host using 80 port.

$ sudo pierrot vhost
#[PM2] Spawning PM2 daemon 
#[PM2] PM2 Successfully daemonized 
#process name not found 
#┌──────────┬────┬──────┬───────┬────────┬─────────┬────────┬─────────────┬──────────┐ 
#│ App name │ id │ mode │ pid   │ status │ restart │ uptime │ memory      │ watching │ 
#├──────────┼────┼──────┼───────┼────────┼─────────┼────────┼─────────────┼──────────┤ 
#│ VHOST    │ 0  │ fork │ 85314 │ online │ 0       │ 0s     │ 29.520 MB   │ disabled │ 
#└──────────┴────┴──────┴───────┴────────┴─────────┴────────┴─────────────┴──────────┘ 
# 
#successfully `vhost`. 
# 
#  Please fix: 
# 
#  $ sudo chmod -R 777 ~/.pm2 
# 
#  See: https://github.com/Unitech/PM2/issues/837 
# 
$ sudo chmod -R 777 ~/.pm2

Deploy the app in local.

$ pierrot apps
? apps homepage
? task initialize
? really Yes
# apps: git clone https://github.com/59naga/berabou.me.git homepage 
# apps/homepage: npm install --production 
# apps/homepage: delete and start pm2 process 
# process name not found 
#  
# homepage was successfully the `initialize` 
#  
# ┌──────────┬────┬──────┬───────┬────────┬─────────┬────────┬─────────────┬──────────┐ 
# │ App name │ id │ mode │ pid   │ status │ restart │ uptime │ memory      │ watching │ 
# ├──────────┼────┼──────┼───────┼────────┼─────────┼────────┼─────────────┼──────────┤ 
# │ VHOST    │ 0  │ fork │ 85314 │ online │ 0       │ 3m     │ 29.520 MB   │ disabled │ 
# │ homepage │ 1  │ fork │ 85830 │ online │ 0       │ 0s     │ 34.074 MB   │ disabled │ 
# └──────────┴────┴──────┴───────┴────────┴─────────┴────────┴─────────────┴──────────┘ 

Becomes...

$ tree
# . 
# ├── node_modules 
# ├── package.json 
# ├── pierrot.yml 
# └── apps 
#      └── homepage 
#          ├── node_modules 
#          ├── package.json 
#          └── ... 

And be available the http://59naga.localhost if Add 127.0.0.1 59naga.localhost to /etc/hosts.

Pierrot tasks

Always set the production to process.env.NODE_ENV.

reload

  1. Pulling repositories in specified apps (eg cd apps/name && git pull).
  2. Reload the processes. (eg pm2 reload <apps...>)

update

  1. Pulling repositories in specified apps (eg cd apps/name && git pull).
  2. Install dependencies. (eg npm install --production)
  3. Reload the processes. (eg pm2 reload <apps...>)

deleteAndStart

  1. Remove the processes. (eg pm2 delete <apps...>)
  2. Start the processes using pierrot.yml^1. (eg pm2 start <apps...>)

initialize

  1. Delete the folder of apps if has apps/repo. (eg rm -rf <apps/name>)
  2. Clone the apps/repo as apps/name. (eg git clone apps/repoValue apps/name)
  3. Install dependencies. (eg cd apps/name && npm install --production)
  4. Start the processes using pierrot.yml. (eg pm2 start <apps...>)

302 redirect

VHOST sends the Location header in the 302 if specify app/to as string.

  oldSite:
    from: oldsite.example.com
    to: renewal.example.com
pm2 reload VHOST
# ... 
 
curl oldsite.example.com/foo/bar?baz --head
# HTTP/1.1 302 Found 
# Location: http://renewal.example.com/foo/bar?baz 
# Date: Mon, 02 Nov 2015 03:36:34 GMT 
# Connection: keep-alive 

https

Define key and cert fields to ./pierrot.yml. Becomes add the port 443(secure mode) at pierrot vhost.

key: /path/to/private.key
cert: /path/to/public.cert
 
apps:
  homepage:
    repo: https://github.com/59naga/berabou.me.git
    from: 59naga.localhost
    to: 59798
$ sudo pierrot vhost
$ pm2 logs VHOST
# PIERROT_VHOST listening at http://localhost:80/ 
# PIERROT_VHOST listening at http://localhost:443/ 

License

MIT

Readme

Keywords

Package Sidebar

Install

npm i pierrot

Weekly Downloads

0

Version

0.0.0-beta.1

License

MIT

Last publish

Collaborators

  • 59naga