Skip to content

Commit

Permalink
refactor(worker): simplify job declaration #9
Browse files Browse the repository at this point in the history
  • Loading branch information
tuana9a committed Sep 14, 2024
1 parent 44c1994 commit d5b99fc
Show file tree
Hide file tree
Showing 29 changed files with 700 additions and 2,226 deletions.
2 changes: 1 addition & 1 deletion docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ services:
volumes:
- ./worker/:/app/
working_dir: /app
command: bash -c "npm install && npx tsc && ./launch.js"
command: bash -c "npm install && npx tsc && node ./dist/launch-worker-rabbitmq-v1.js"
networks:
net1:
ipv4_address: 172.222.0.6
Expand Down
4 changes: 1 addition & 3 deletions worker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,5 @@ WORKDIR /app
COPY package.json .
RUN npm install
COPY src src
COPY launch.js .
COPY tsconfig.json .
RUN npm run build
CMD [ "launch.js" ]
RUN npm run build
64 changes: 0 additions & 64 deletions worker/launch.js

This file was deleted.

56 changes: 48 additions & 8 deletions worker/src/configs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ const DEFAULT_LOG_DEST = "cs";

export class Config {
id?: string = String(Date.now());
type?: string = "";
logDest?: string = DEFAULT_LOG_DEST;
jobDir?: string = DEFAULT_JOB_DIR;
tmpDir?: string = DEFAULT_TMP_DIR;
Expand All @@ -24,12 +23,6 @@ export class Config {
// rabbit worker
rabbitmqConnectionString?: string = "";
amqpEncryptionKey?: string = "";

toJson() {
return {
...this,
};
}
}

export const cfg = new Config();
Expand Down Expand Up @@ -59,4 +52,51 @@ export const correctConfig = (c: Config) => {
c.puppeteerLaunchOptions = c.puppeteerLaunchOptions || {};
c.puppeteerLaunchOptions.userDataDir = c.puppeteerLaunchOptions.userDataDir || DEFAULT_USER_DATA_DIR;
return c;
};
};

export const puppeteerLaunchOptions = {};
puppeteerLaunchOptions["docker"] = {
"args": [
"--no-sandbox",
"--disable-setuid-sandbox"
],
"slowMo": 10,
"defaultViewport": {
"width": 1920,
"height": 1080
},
"executablePath": "google-chrome-stable",
"userDataDir": "./userdata.tmp/"
}
puppeteerLaunchOptions["linux-headless"] = {
"slowMo": 10,
"defaultViewport": {
"width": 1920,
"height": 1080
},
"executablePath": "google-chrome-stable",
"userDataDir": "./userdata.tmp/"
}
puppeteerLaunchOptions["linux-visible"] = {
"slowMo": 10,
"headless": false,
"defaultViewport": null,
"executablePath": "google-chrome-stable",
"userDataDir": "./userdata.tmp/"
}
puppeteerLaunchOptions["window-headless"] = {
"slowMo": 10,
"defaultViewport": {
"width": 1920,
"height": 1080
},
"executablePath": "C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe",
"userDataDir": "./userdata.tmp/"
}
puppeteerLaunchOptions["window-visible"] = {
"headless": false,
"slowMo": 10,
"defaultViewport": null,
"executablePath": "C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe",
"userDataDir": "./userdata.tmp/"
}
85 changes: 0 additions & 85 deletions worker/src/controllers.ts

This file was deleted.

79 changes: 0 additions & 79 deletions worker/src/index.ts

This file was deleted.

Loading

0 comments on commit d5b99fc

Please sign in to comment.