Upload 3 files
Browse files- Dockerfile +25 -0
- server.js +43 -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/hakisolos/nikka-v3.2 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,43 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
const http = require('http');
|
2 |
+
const { exec } = require('child_process');
|
3 |
+
const PORT = 7860;
|
4 |
+
const RESTART_INTERVAL_MS = 5 * 60 * 60 * 1000; // 5 hours in milliseconds
|
5 |
+
|
6 |
+
const startServer = () => {
|
7 |
+
const server = http.createServer((req, res) => {
|
8 |
+
res.writeHead(200, { 'Content-Type': 'text/html' });
|
9 |
+
res.end('<html><body><b><marquee>KING Alya<marquee></b></body></html>');
|
10 |
+
});
|
11 |
+
|
12 |
+
server.listen(PORT, () => {
|
13 |
+
console.log(`Server listening on port ${PORT}`);
|
14 |
+
});
|
15 |
+
|
16 |
+
return server;
|
17 |
+
};
|
18 |
+
|
19 |
+
let server = startServer();
|
20 |
+
|
21 |
+
// Function to restart the server
|
22 |
+
const restartServer = () => {
|
23 |
+
console.log('Restarting server...');
|
24 |
+
|
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);
|
33 |
+
|
34 |
+
// Error handling
|
35 |
+
process.on('uncaughtException', (err) => {
|
36 |
+
console.error('Uncaught Exception:', err);
|
37 |
+
restartServer();
|
38 |
+
});
|
39 |
+
|
40 |
+
process.on('unhandledRejection', (reason, promise) => {
|
41 |
+
console.error('Unhandled Rejection at:', promise, 'reason:', reason);
|
42 |
+
restartServer();
|
43 |
+
});
|
start.sh
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
node server.js & npm start
|