Skip to content

Commit ebcb8d5

Browse files
committed
update
1 parent a7f7f0f commit ebcb8d5

File tree

4 files changed

+53
-27
lines changed

4 files changed

+53
-27
lines changed

Dockerfile

+21-11
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,30 @@
1-
# Base image
2-
FROM node:18
1+
FROM node:16
32

4-
# Create app directory
5-
WORKDIR /usr/src/app
3+
# Set working directory
4+
WORKDIR /app
65

7-
# A wildcard is used to ensure both package.json AND package-lock.json are copied
6+
# Copy package.json and package-lock.json
87
COPY package*.json ./
98

10-
# Install app dependencies
9+
# Install dependencies
1110
RUN npm install
1211

13-
# Bundle app source
12+
# Copy the rest of the application files
1413
COPY . .
1514

16-
# Creates a "dist" folder with the production build
17-
RUN npm run build
15+
# Expose the application port
16+
EXPOSE 2000
1817

19-
# Start the server using the production build
20-
CMD [ "node", "dist/main.js" ]
18+
# Install Redis server
19+
RUN apt-get update && \
20+
apt-get install -y redis-server && \
21+
rm -rf /var/lib/apt/lists/*
22+
23+
# Configure Redis to listen on port 6377 without a password
24+
RUN sed -i 's/^bind .*$/bind 0.0.0.0/' /etc/redis/redis.conf && \
25+
sed -i 's/^protected-mode yes$/protected-mode no/' /etc/redis/redis.conf && \
26+
sed -i 's/^port 6379$/port 6377/' /etc/redis/redis.conf && \
27+
sed -i '/^requirepass/ s/^/#/' /etc/redis/redis.conf
28+
29+
# Start Redis server and then the Node.js application
30+
CMD ["bash", "-c", "redis-server --daemonize yes && npm start"]

docker-compose.yml

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
version: '3'
2+
3+
services:
4+
app:
5+
build:
6+
context: .
7+
dockerfile: Dockerfile
8+
ports:
9+
- "2000:2000"

src/checker/checker.processor.ts

+21-14
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,14 @@ export class CheckerProcesspr {
1212
constructor(private websocketGatway: WebsocketGateway) { }
1313
@Process({
1414
name: 'CHECK_PROXY',
15-
concurrency: 50,
15+
concurrency: 250,
1616
})
1717
async scrapLink(job: Job<any>) {
1818
console.log(job.data)
1919
return await this.httpChecker(job.data.proxy, job.data.isLast);
2020
}
2121

22-
async httpChecker(proxy:string,isLast:boolean) {
22+
async httpChecker(proxy: string, isLast: boolean) {
2323
const httpAgent = new HttpProxyAgent(`http://${proxy}`);
2424
const startTime: any = new Date();
2525

@@ -34,13 +34,16 @@ export class CheckerProcesspr {
3434
let geo = await lookup(proxy.split(':')[0])
3535
let proxyData = {
3636
proxy,
37-
status: 'LIVE',
38-
latency: `${latency} ms`,
39-
type: res.data.headers['X-Forwarded-Proto'],
40-
geo: { ...geo }
37+
data: {
38+
status: 'LIVE',
39+
latency: `${latency} ms`,
40+
type: res.data.headers['X-Forwarded-Proto'],
41+
geo: { ...geo }
42+
}
43+
4144
}
4245
this.websocketGatway.handleMessage(proxyData)
43-
if(isLast){
46+
if (isLast) {
4447
this.websocketGatway.handleMessage({
4548
status: 'DONE',
4649
})
@@ -49,27 +52,31 @@ export class CheckerProcesspr {
4952
}
5053
this.websocketGatway.handleMessage({
5154
proxy,
52-
status: 'DEAD',
55+
data : {
56+
status: 'DEAD',
57+
}
5358
})
54-
if(isLast){
59+
if (isLast) {
5560
this.websocketGatway.handleMessage({
5661
status: 'DONE',
5762
})
5863
}
59-
return { proxy,status: 'DEAD' };
64+
return { proxy, status: 'DEAD' };
6065
} catch (error) {
6166
this.websocketGatway.handleMessage({
6267
proxy,
63-
status: 'DEAD',
68+
data : {
69+
status: 'DEAD',
70+
}
6471
})
65-
if(isLast){
72+
if (isLast) {
6673
this.websocketGatway.handleMessage({
6774
status: 'DONE',
6875
})
6976
}
70-
return { proxy,status: 'DEAD' };
77+
return { proxy, status: 'DEAD' };
7178
}
72-
79+
7380
}
7481

7582
}

src/main.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,6 @@ async function bootstrap() {
3535
'https://cdnjs.cloudflare.com/ajax/libs/swagger-ui/4.15.5/swagger-ui.css',
3636
],
3737
});
38-
await app.listen(process.env.PORT || 5000);
38+
await app.listen(process.env.PORT || 2000);
3939
}
40-
bootstrap();
40+
bootstrap();

0 commit comments

Comments
 (0)