Skip to content

Commit 2a135f2

Browse files
committed
Add dotenv and npmlog support; implement command handling and server logging
- Enhanced index.ts to load commands dynamically and log server events. - Created .env.example for environment variable configuration. - Added GitHub Actions workflow for automated builds. - Introduced ecosystem.config.js for process management with PM2.
1 parent 10ba1b0 commit 2a135f2

8 files changed

Lines changed: 343 additions & 13 deletions

File tree

.env.example

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
PROJECT_CANIS_ALIAS=Canis
2+
COMMAND_PREFIX=!
3+
PORT=3000

.github/workflows/build.yml

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: Build
2+
3+
on:
4+
push:
5+
branches: ["master"]
6+
pull_request:
7+
branches: ["master"]
8+
workflow_dispatch:
9+
10+
jobs:
11+
build:
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- uses: actions/checkout@v4
16+
- name: Use Node.js
17+
uses: actions/setup-node@v4
18+
with:
19+
node-version: 24
20+
21+
- name: Clean Install Dependencies
22+
run: npm ci
23+
24+
- name: Build project
25+
run: npm run build
26+
27+
- name: Copy files to dist
28+
run: |
29+
cp package-lock.json dist/
30+
cp package.json dist/
31+
cp README.md dist/
32+
cp LICENSE dist/
33+
cp .env.example dist/
34+
cp .dockerignore dist/
35+
cp .gitignore dist/
36+
cp Dockerfile dist/
37+
cp ecosystem.config.js dist/
38+
echo "Build Date: $(date)" >> dist/build-info.txt
39+
40+
- name: Get latest commit hash
41+
run: |
42+
echo "MASTER_COMMIT_HASH=$(git rev-parse --short HEAD)" >> $GITHUB_ENV
43+
echo "COMMIT_URL=https://github.com/${{ github.repository }}/commit/$(git rev-parse HEAD)" >> $GITHUB_ENV
44+
45+
- name: Upload
46+
id: push_directory
47+
uses: cpina/github-action-push-to-another-repository@main
48+
env:
49+
API_TOKEN_GITHUB: ${{ secrets.API_TOKEN_GITHUB }}
50+
with:
51+
source-directory: dist/
52+
destination-github-username: 'mrepol742'
53+
destination-repository-name: 'project-canis'
54+
user-name: github-actions[bot]
55+
user-email: github-actions[bot]@users.noreply.github.com
56+
commit-message: "Build from ${{ env.COMMIT_URL }}"
57+
target-branch: build

ecosystem.config.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
module.exports = {
2+
apps: [
3+
{
4+
name: "project-canis",
5+
script: "dist/index.js",
6+
instances: 3,
7+
exec_mode: "cluster",
8+
sticky: true,
9+
node_args: "--max-old-space-size=1024",
10+
env: {
11+
NODE_ENV: "production",
12+
},
13+
max_memory_restart: "512M",
14+
watch: false,
15+
autorestart: true,
16+
},
17+
],
18+
};

package-lock.json

Lines changed: 186 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)