mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-23 14:15:13 +00:00
chore(examples): zero-downtime pm2 typescript example (#4907)
This commit is contained in:
parent
47898fbdac
commit
1fb9af33a3
26
examples/pm2-typescript/README.md
Normal file
26
examples/pm2-typescript/README.md
Normal file
@ -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`
|
13
examples/pm2-typescript/ecosystem.config.js
Normal file
13
examples/pm2-typescript/ecosystem.config.js
Normal file
@ -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
|
||||
}
|
||||
]
|
||||
}
|
9
examples/pm2-typescript/nuxt.config.ts
Normal file
9
examples/pm2-typescript/nuxt.config.ts
Normal file
@ -0,0 +1,9 @@
|
||||
export default {
|
||||
hooks: {
|
||||
listen () {
|
||||
if (process.send) {
|
||||
process.send('ready')
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
18
examples/pm2-typescript/package.json
Normal file
18
examples/pm2-typescript/package.json
Normal file
@ -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"
|
||||
}
|
||||
}
|
12
examples/pm2-typescript/pages/index.vue
Normal file
12
examples/pm2-typescript/pages/index.vue
Normal file
@ -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>
|
10
examples/pm2-typescript/tsconfig.json
Normal file
10
examples/pm2-typescript/tsconfig.json
Normal file
@ -0,0 +1,10 @@
|
||||
{
|
||||
"extends": "@nuxt/typescript",
|
||||
"compilerOptions": {
|
||||
"baseUrl": ".",
|
||||
"types": [
|
||||
"@types/node",
|
||||
"@nuxt/vue-app"
|
||||
]
|
||||
}
|
||||
}
|
9
examples/pm2-typescript/tslint.json
Normal file
9
examples/pm2-typescript/tslint.json
Normal file
@ -0,0 +1,9 @@
|
||||
{
|
||||
"defaultSeverity": "error",
|
||||
"extends": [
|
||||
"tslint-config-standard"
|
||||
],
|
||||
"rules": {
|
||||
"prefer-const": true
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user