Add route, Update workflow
This commit is contained in:
parent
f1b14ac7ea
commit
296c006fd9
4 changed files with 96 additions and 26 deletions
|
|
@ -7,31 +7,31 @@ on:
|
|||
- 'v*'
|
||||
- 'release-*'
|
||||
jobs:
|
||||
# build-and-test:
|
||||
# runs-on: docker
|
||||
# container:
|
||||
# image: node:20-slim
|
||||
# steps:
|
||||
# - name: Checkout code
|
||||
# uses: actions/checkout@v4
|
||||
# - name: Set up timezone
|
||||
# run: |
|
||||
# apt-get update && apt-get install -y tzdata
|
||||
# ln -snf /usr/share/zoneinfo/Asia/Bangkok /etc/localtime
|
||||
# echo "Asia/Bangkok" > /etc/timezone
|
||||
# rm -rf /var/lib/apt/lists/*
|
||||
# - name: Cache npm dependencies
|
||||
# uses: actions/cache@v3
|
||||
# with:
|
||||
# path: ~/.npm
|
||||
# key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
|
||||
# restore-keys: |
|
||||
# ${{ runner.os }}-node-
|
||||
# - name: Install dependencies
|
||||
# run: npm install
|
||||
# - name: Show heartbeat.js version and changelogs
|
||||
# run: |
|
||||
# awk '/const heartbeatApiInfo = {/,/};/' plugins/heartbeat.js | sed -n '/version:/,/],/p'
|
||||
build-and-test:
|
||||
runs-on: docker
|
||||
container:
|
||||
image: node:20-slim
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
- name: Set up timezone
|
||||
run: |
|
||||
apt-get update && apt-get install -y tzdata
|
||||
ln -snf /usr/share/zoneinfo/Asia/Bangkok /etc/localtime
|
||||
echo "Asia/Bangkok" > /etc/timezone
|
||||
rm -rf /var/lib/apt/lists/*
|
||||
- name: Cache npm dependencies
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
path: ~/.npm
|
||||
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-node-
|
||||
- name: Install dependencies
|
||||
run: npm install
|
||||
- name: Show version and changelogs from all plugins
|
||||
run: |
|
||||
find plugins -type f -name "*.js" -exec sh -c 'echo "From file: {}"; awk "/version:/{flag=1} flag{print} /]/||/}/{flag=0}" "{}" | sed -n "/version:/,/]/p"' \;
|
||||
# - name: Run application
|
||||
# run: npm start
|
||||
# env:
|
||||
|
|
|
|||
4
app.js
4
app.js
|
|
@ -6,6 +6,7 @@ var cookieParser = require("cookie-parser");
|
|||
|
||||
var indexRouter = require("./routes/index");
|
||||
var usersRouter = require("./routes/users");
|
||||
var healthRouter = require("./routes/health")
|
||||
// const { createLogger, format, transports } = require('winston');
|
||||
|
||||
const {
|
||||
|
|
@ -39,6 +40,7 @@ app
|
|||
|
||||
app.use("/", indexRouter);
|
||||
app.use("/users", usersRouter);
|
||||
app.use("/health", healthRouter);
|
||||
|
||||
Log.debug(`running on port ${process.env.PORT}`);
|
||||
|
||||
|
|
@ -86,7 +88,7 @@ GoogleFunctions.syncProfilePrice(sheet, "tha", false);
|
|||
//
|
||||
|
||||
// Test Taobin SyncText
|
||||
SyncText.run(sheet, "uae", false);
|
||||
// SyncText.run(sheet, "uae", false);
|
||||
|
||||
const pm = new PluginsManager(cronTasks, CronJobs);
|
||||
pm.load();
|
||||
|
|
|
|||
48
docker-compose.yml
Normal file
48
docker-compose.yml
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
version: '3.8'
|
||||
|
||||
services:
|
||||
my-express-app:
|
||||
image: pakin-inspiron-15-3530.tail110d9.ts.net/my-express-app:1.0.0
|
||||
container_name: my-express-app
|
||||
restart: unless-stopped
|
||||
ports:
|
||||
- "3000:3000"
|
||||
|
||||
# 🔑 KEY: These labels make your app discoverable and manageable
|
||||
labels:
|
||||
# Enable automatic updates
|
||||
- "silserv.enable=true"
|
||||
|
||||
# Registry configuration
|
||||
- "silserv.registry=pakin-inspiron-15-3530.tail110d9.ts.net"
|
||||
- "silserv.image=my-express-app"
|
||||
|
||||
# Health check endpoint
|
||||
- "silserv.health-path=/health"
|
||||
|
||||
# Update strategy: automatic, manual, or cron expression
|
||||
- "silserv.strategy=automatic"
|
||||
|
||||
# Optional: Additional metadata
|
||||
# - "silserv.<metadata_name>=<metadata_value>"
|
||||
- "silserv.description=My Express Application"
|
||||
- "silserv.team=backend"
|
||||
|
||||
# 🌐 IMPORTANT: Must be on the update-manager network
|
||||
networks:
|
||||
- silserv-network
|
||||
|
||||
environment:
|
||||
- NODE_ENV=production
|
||||
- APP_VERSION=1.0.0
|
||||
|
||||
# Health check for Docker
|
||||
healthcheck:
|
||||
test: ["CMD", "curl", "-f", "http://localhost:3000/health"]
|
||||
interval: 30s
|
||||
timeout: 10s
|
||||
retries: 3
|
||||
|
||||
networks:
|
||||
silserv-network:
|
||||
external: true
|
||||
20
routes/health.js
Normal file
20
routes/health.js
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
var express = require('express');
|
||||
var router = express.Router();
|
||||
|
||||
const healthStatus = [
|
||||
"OK",
|
||||
"FAIL"
|
||||
]
|
||||
|
||||
router.get('/', function (req, res) {
|
||||
const jobs = CronJobs.getAllRunning;
|
||||
const data = [];
|
||||
|
||||
for (let [name, job] of jobs) {
|
||||
data.push({ name, status: healthStatus[0] });
|
||||
}
|
||||
|
||||
res.json({ data });
|
||||
});
|
||||
|
||||
module.exports = router;
|
||||
Loading…
Add table
Add a link
Reference in a new issue