add script for deploy

This commit is contained in:
CounterFire2023 2024-04-16 15:06:37 +08:00
parent 9513fab283
commit 627b3e34ff
6 changed files with 58 additions and 9 deletions

13
bundle.sh Executable file
View File

@ -0,0 +1,13 @@
#!/bin/bash
source /etc/profile
module_sub_path=$module_path"/node_modules"
yarn install --prefer-offline --loglevel info --unsafe-perm=true --allow-root >> boundle.log
yarn build >> boundle.log
tar -zcvf task-svr.tar.gz ./
mkdir target && mv ./task-svr.tar.gz ./target/task-svr.tar.gz
echo 'all done' 2>&1 >> boundle.log

10
configs/constants.json Normal file
View File

@ -0,0 +1,10 @@
{
"STEP_SCORE_MIN": 40,
"STEP_SCORE_MAX": 50,
"STEP_CHEST_RATE": 1,
"INVITE_REBATE": 0.1,
"MAX_ENHANCE_COUNT_BASE": 1,
"MAX_ENHANCE_COUNT_ADV": 10,
"ENHANCE_CHEST_GIFT": 10,
"BASE_TASK_TICKET": 3
}

2
restart.sh Normal file
View File

@ -0,0 +1,2 @@
pm2 stop task:release && pm2 delete task:release && pm2 start start_production.json

View File

@ -14,26 +14,28 @@ export const CONFIRM_MAIL_HTML = `
<p>, , , , 使MetaMask的浏览器打开</p>
<p><a href="{{link}}" target="_blank">{{link2}}</a></p>
`
const cfg = require('../../configs/constants.json')
// 是否需要手动开启游戏
export const MANUAL_OPEN_GAME = false
// 每一步能获得的最小分数
export const STEP_SCORE_MIN = 40
export const STEP_SCORE_MIN = cfg.STEP_SCORE_MIN || 40
// 每一步能获得的最大分数
export const STEP_SCORE_MAX = 50
export const STEP_SCORE_MAX = cfg.STEP_SCORE_MAX || 50
// 每一步能获得的宝箱的概率
export const STEP_CHEST_RATE = 1
export const STEP_CHEST_RATE = cfg.STEP_CHEST_RATE || 1
// 邀请用户得到额外分数
export const INVITE_REBATE = 0.1
export const INVITE_REBATE = cfg.INVITE_REBATE || 0.1
// 基础用户每日可助力次数
export const MAX_ENHANCE_COUNT_BASE = 1
export const MAX_ENHANCE_COUNT_BASE = cfg.MAX_ENHANCE_COUNT_BASE || 1
// 高级用户每日可助力次数
export const MAX_ENHANCE_COUNT_ADV = 10
export const MAX_ENHANCE_COUNT_ADV = cfg.MAX_ENHANCE_COUNT_ADV || 10
// 宝箱助力增加的分数
export const ENHANCE_CHEST_GIFT = 10
export const ENHANCE_CHEST_GIFT = cfg.ENHANCE_CHEST_GIFT || 10
// 完成所有基础任务额外奖励的ticket
export const BASE_TASK_TICKET = 3
export const BASE_TASK_TICKET = cfg.BASE_TASK_TICKET || 3
// 低保步数
export const RESET_STEP = 2

View File

@ -5,7 +5,7 @@ const SECRET_KEY = process.env.HASH_SALT
const DEFAULT_TIMEOUT = 30000
function createSign(address: string) {
// address = address.toLowerCase();
address = address.toLowerCase()
let signCheck = hmacSha256(`address=${address}`, SECRET_KEY)
return signCheck
}

22
start_production.json Normal file
View File

@ -0,0 +1,22 @@
{
"apps": [
{
"name": "task:release",
"script": "npm",
"args": "run prod:api",
"cwd": "/data/apps/task-svr",
"max_memory_restart": "1024M",
"log_date_format": "YYYY-MM-DD HH:mm Z",
"watch": false,
"ignore_watch": ["node_modules", "logs", "fixtures", "tasks"],
"instances": 1,
"exec_mode": "fork",
"env": {
"NODE_ENV": "production"
},
"env_production": {
"NODE_ENV": "production"
}
}
]
}