chore: update script

This commit is contained in:
Innei
2021-09-11 10:19:00 +08:00
parent 3382aaaf95
commit c8c9208f69
4 changed files with 15 additions and 27 deletions

View File

@@ -36,6 +36,7 @@ jobs:
run: |
pnpm run bundle
cp -R assets out
cp ecosystem.config.js out
cd out
zip -r ../release.zip ./*
- name: Create Release

View File

@@ -1,3 +1,6 @@
set -e
git pull --rebase
pnpm i
yarn version --no-git-tag-version
tag=v$(json -f package.json version)
git add .

View File

@@ -1,29 +1,13 @@
/*
* @Author: Innei
* @Date: 2020-04-30 18:14:55
* @LastEditTime: 2020-05-25 21:05:26
* @LastEditors: Innei
* @FilePath: /mx-server/ecosystem.config.js
* @Copyright
*/
// eslint-disable-next-line @typescript-eslint/no-var-requires
const env = require('dotenv').config().parsed
module.exports = {
apps: [
{
name: 'mx-space-server@next',
script: 'dist/src/main.js',
name: 'mx-server',
script: 'index.js',
autorestart: true,
instances: 'max',
exec_mode: 'cluster',
watch: false,
// instances: 1,
// max_memory_restart: env.APP_MAX_MEMORY || '150M',
env: {
NODE_ENV: 'production',
...env,
},
instances: 2,
max_memory_restart: '230M',
},
],
}

View File

@@ -1,5 +1,5 @@
// @ts-check
const { $, cd, fetch } = require('zx')
const { $, cd, fetch, nothrow } = require('zx')
const fs = require('fs')
const { sleep } = require('zx')
const { homedir } = require('os')
@@ -21,7 +21,7 @@ async function main() {
)?.browser_download_url
if (!downloadUrl) {
return
throw new Error('no download url found')
}
const buffer = await fetch(
@@ -31,16 +31,16 @@ async function main() {
fs.writeFileSync(`/tmp/${tmpName}.zip`, buffer, { flag: 'w' })
await $`rm -rf ./run`
await $`unzip /tmp/${tmpName}.zip -d ./run`
try {
await $`pm2 stop mx-server`
} catch {}
await $`pm2 start ./run/index.js --max-memory-restart 250M --name mx-server -- ${argv}`
await $`rm /tmp/${tmpName}.zip`
cd('./run')
await nothrow($`pm2 reload ecosystem.config.js -- ${argv}`)
console.log('等待 15 秒')
await sleep(15000)
try {
await $`lsof -i:2333 -P -n | grep LISTEN`
} catch {
await $`pm2 stop ./run/index.js`
await $`pm2 stop ecosystem.config.js`
throw new Error('server is not running')
}
}