Spaces:
Building
Building
Akaymighty
commited on
Commit
•
9f42e1b
1
Parent(s):
0294c05
Upload 3 files
Browse files- Dockerfile +25 -0
- server.js +32 -0
- start.sh +1 -0
Dockerfile
ADDED
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
FROM node:20
|
2 |
+
|
3 |
+
|
4 |
+
USER node
|
5 |
+
|
6 |
+
|
7 |
+
RUN git clone https://github.com/Akay-mighty/Queen_Alya1 home/node/blue
|
8 |
+
|
9 |
+
|
10 |
+
WORKDIR /home/node/blue
|
11 |
+
|
12 |
+
|
13 |
+
RUN chmod -R 777 /home/node/blue/
|
14 |
+
|
15 |
+
|
16 |
+
RUN yarn install && yarn add http
|
17 |
+
|
18 |
+
|
19 |
+
COPY server.js .
|
20 |
+
|
21 |
+
|
22 |
+
COPY start.sh .
|
23 |
+
|
24 |
+
|
25 |
+
CMD ["bash","start.sh" ]
|
server.js
ADDED
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
const http = require('http');
|
2 |
+
const { exec } = require('child_process');
|
3 |
+
|
4 |
+
const PORT = 7860;
|
5 |
+
const RESTART_INTERVAL_MS = 5 * 60 * 60 * 1000; // 5 hours in milliseconds
|
6 |
+
|
7 |
+
const startServer = () => {
|
8 |
+
const server = http.createServer((req, res) => {
|
9 |
+
res.writeHead(200, { 'Content-Type': 'text/html' });
|
10 |
+
res.end('<html><body><b><marquee>KING Alya<marquee></b></body></html>');
|
11 |
+
});
|
12 |
+
|
13 |
+
server.listen(PORT, () => {
|
14 |
+
console.log(`Server listening on port ${PORT}`);
|
15 |
+
});
|
16 |
+
|
17 |
+
return server;
|
18 |
+
};
|
19 |
+
|
20 |
+
let server = startServer();
|
21 |
+
|
22 |
+
// Function to restart the server
|
23 |
+
const restartServer = () => {
|
24 |
+
console.log('Restarting server...');
|
25 |
+
server.close(() => {
|
26 |
+
console.log('Server stopped.');
|
27 |
+
server = startServer();
|
28 |
+
});
|
29 |
+
};
|
30 |
+
|
31 |
+
// Set up the interval to restart the server every 5 hours
|
32 |
+
setInterval(restartServer, RESTART_INTERVAL_MS);
|
start.sh
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
node server.js & npm start
|