Skip to content

Commit f1fe55b

Browse files
committed
refact: add timestamp to logs
1 parent ddafa78 commit f1fe55b

File tree

4 files changed

+39
-2
lines changed

4 files changed

+39
-2
lines changed
+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: Docker Image CI
2+
3+
on:
4+
push:
5+
branches: [ "dev" ]
6+
jobs:
7+
build:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- uses: actions/checkout@v4
11+
- name: Log in to Docker Hub
12+
uses: docker/[email protected]
13+
with:
14+
username: ${{ secrets.DOCKER_USERNAME }}
15+
password: ${{ secrets.DOCKER_PASSWORD }}
16+
- name: Set up QEMU
17+
uses: docker/setup-qemu-action@v3
18+
- name: Set up Docker Buildx
19+
uses: docker/setup-buildx-action@v2
20+
- name: Build and push Docker image
21+
id: push
22+
uses: docker/[email protected]
23+
with:
24+
platforms: linux/amd64,linux/arm64
25+
context: .
26+
file: ./Dockerfile
27+
push: true
28+
tags: overtrue/gradient-bot:dev

Dockerfile

+6
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,12 @@ ADD . /app/
3030
# install dependencies
3131
RUN npm install --omit=dev
3232
RUN npm install pm2 -g
33+
RUN pm2 install pm2-logrotate
34+
RUN pm2 set pm2-logrotate:compress true
35+
RUN pm2 set pm2-logrotate:dateFormat YYYY-MM-DD_HH-mm-ss
36+
RUN pm2 set pm2-logrotate:rotateInterval '*/5 * * * *'
37+
RUN pm2 set pm2-logrotate:max_size 10M
38+
RUN pm2 set pm2-logrotate:retain 2
3339
RUN SE_AVOID_BROWSER_DOWNLOAD=false SE_OFFLINE=false ./node_modules/selenium-webdriver/bin/linux/selenium-manager --browser chrome --output SHELL --browser-version $SE_BROWSER_VERSION
3440
RUN chmod +x /app/entrypoint.sh
3541

entrypoint.sh

+3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
#!/bin/bash
22

3+
pm2 flush
4+
pm2 delete all
5+
36
node /app/start.js
47

58
pm2 logs

start.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,14 @@ if (!USER || !PASSWORD) {
2525

2626
if (proxies.length === 0) {
2727
console.error("No proxies found in proxies.txt, will start app without proxy...")
28-
execSync(`APP_USER='${USER}' APP_PASS='${PASSWORD}' pm2 start app.js --name gradient-bot-no-proxy`)
28+
execSync(`APP_USER='${USER}' APP_PASS='${PASSWORD}' pm2 start app.js --name gradient-bot-no-proxy -l gradient-bot-no-proxy.log`)
2929
console.log('-> √ Started gradient-bot-no-proxy')
3030
} else {
3131
console.log(`-> Found ${proxies.length} proxies in proxies.txt`)
3232
let index = 0
3333
for (const proxy of proxies) {
3434
const name = `gradient-${index++}`
35-
execSync(`PROXY=${proxy} APP_USER='${USER}' APP_PASS='${PASSWORD}' pm2 start app.js --name ${name}`)
35+
execSync(`PROXY=${proxy} APP_USER='${USER}' APP_PASS='${PASSWORD}' pm2 start app.js --name ${name} -l ${name}.log`)
3636
console.log(`-> Started ${name} with proxy ${proxy}`)
3737
}
3838

0 commit comments

Comments
 (0)