Skip to content

Commit

Permalink
Merge pull request #2 from catalyzt-tech/RPGF-41/fix-cron
Browse files Browse the repository at this point in the history
[RPGF-41] Fix CRON Job
  • Loading branch information
wit03 authored Aug 27, 2024
2 parents d10086d + 1cc06c9 commit 31a6d2c
Show file tree
Hide file tree
Showing 21 changed files with 1,148 additions and 213 deletions.
6 changes: 5 additions & 1 deletion .env.sample
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
NODE_ENV=dev
GITHUB_KEY=
API_PASSWORD=
PORT=3002
CORS=
# API_SECRET=
# CLOUD_NAME=
# API_KEY=
# API_KEY=
2 changes: 1 addition & 1 deletion .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
with:
context: .
file: Dockerfile
platforms: linux/amd64
platforms: linux/aarch64
push: true
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest
- name: Deploy to Coolify
Expand Down
7 changes: 7 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
serve:
pnpm dev:Serve


build:
pnpm run build
node dist/src/index.js
19 changes: 18 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@ Worker dynamically imports and executes TypeScript files from the `src/scripts`
- `src/scripts`: add folder of the module and add the TypeScript file here the example is `example.ts`
- It should export a `Run` function that will be executed by the worker
- It should export a `DATA_DIR` variable that will be used to save the data
- It should export a `cronTimer` variable that will be used to set the cron job timer
- It should export a `MODULE_NAME` variable that will be used to set the module name
- It should export a `CRON_TIMER` variable that will be used to set the cronjob timer
- CRON_TIMER is the cronjob timer for the module, it can be undefined if the module is not a cronjob
- Visit https://github.com/node-cron/node-cron to learn the format of cronjob

## Api Route
- Get /api/ will list all the static file that can be served
Expand All @@ -19,3 +21,18 @@ Worker dynamically imports and executes TypeScript files from the `src/scripts`
- Post /api/modules/run/(any-module-name) will run the module
- it required post body with a password


## Development / Deployment
- Developmenet
- if you were on the development mode must change the value of `NODE_ENV` to `dev` and use cli command to run on local
```
pnpm dev:Serve
```
- Deployment
- Must change the value of `NODE_ENV` to `production` and use cli command to run on production
```
pnpm run build
node dist/src/index.js
```
17 changes: 12 additions & 5 deletions build.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
docker buildx build --platform linux/aarch64 -t worker:latest --load .
docker buildx build --platform linux/aarch64 -t worker:v-39 --load .

docker tag worker:latest tgrziminiar/worker:latest
docker tag worker:v-39 tgrziminiar/worker:v-39

docker push tgrziminiar/worker:latest
docker push tgrziminiar/worker:v-39

docker run -d \
-p 3001:3001 \
-p 3002:3002 \
--env-file .env \
--name fukthis \
worker:latest
worker:v-36

docker run -d \
-p 3001:3001 \
-v /etc/timezone:/etc/timezone:ro \
--env-file .env \
--name kuay \
worker:v-8
Loading

0 comments on commit 31a6d2c

Please sign in to comment.