-
-
Notifications
You must be signed in to change notification settings - Fork 5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(examples): zero-downtime pm2 typescript example (#4907)
- Loading branch information
1 parent
47898fb
commit 1fb9af3
Showing
7 changed files
with
97 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# PM2 with nuxt-ts example | ||
|
||
[Gracefull zero-downtime restart](https://pm2.io/doc/en/runtime/best-practices/graceful-shutdown/#graceful-start) | ||
|
||
`ecosystem.config.js` - configuration file for pm2 | ||
|
||
`listen_timeout` option depends on your need | ||
|
||
## Zero-downtime deployment | ||
*all depends on your deployment method. It's just example | ||
|
||
#### Directories: | ||
- `$PROJECT_ROOT` - your project root path on server | ||
- `/current` - root dir for nginx(if you are using [proxy configuration](https://nuxtjs.org/faq/nginx-proxy/)) | ||
- `/_tmp` - Temporary dir to install and build project | ||
- `/_old` - Previous build. Can be useful for fast reverting | ||
|
||
#### Steps: | ||
- deploy project to $PROJECT_ROOT/_tmp | ||
- `cd $PROJECT_ROOT/_tmp` | ||
- `npm i` | ||
- `nuxt build` or if you are using TypeScript `nuxt-ts build` | ||
- `mv $PROJECT_ROOT/current $PROJECT_ROOT/_old` | ||
- `mv $PROJECT_ROOT/_tmp $PROJECT_ROOT/current` | ||
- `cd $PROJECT_PATH/current` | ||
- `pm2 startOrReload ecosystem.config.js` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
module.exports = { | ||
apps: [ | ||
{ | ||
name: 'pm2-nuxt-ts', | ||
script: './node_modules/.bin/nuxt-ts', | ||
args: 'start', | ||
instances: 2, | ||
exec_mode: 'cluster', | ||
wait_ready: true, | ||
listen_timeout: 5000 | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
export default { | ||
hooks: { | ||
listen () { | ||
if (process.send) { | ||
process.send('ready') | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"version": "1.0.0", | ||
"private": true, | ||
"dependencies": { | ||
"nuxt-ts": "latest", | ||
"vue-property-decorator": "^7.3.0" | ||
}, | ||
"scripts": { | ||
"dev": "nuxt-ts", | ||
"build": "nuxt-ts build", | ||
"start": "nuxt-ts start", | ||
"generate": "nuxt-ts generate", | ||
"lint": "tslint --project ." | ||
}, | ||
"devDependencies": { | ||
"tslint-config-standard": "^8.0.1" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<template> | ||
<h1> | ||
Hello world ! | ||
</h1> | ||
</template> | ||
|
||
<script lang="ts"> | ||
import { Component, Vue } from 'vue-property-decorator' | ||
@Component | ||
export default class Home extends Vue {} | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"extends": "@nuxt/typescript", | ||
"compilerOptions": { | ||
"baseUrl": ".", | ||
"types": [ | ||
"@types/node", | ||
"@nuxt/vue-app" | ||
] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"defaultSeverity": "error", | ||
"extends": [ | ||
"tslint-config-standard" | ||
], | ||
"rules": { | ||
"prefer-const": true | ||
} | ||
} |