Compare commits
2
Commits
a21e06bf5b
...
37b2630525
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
37b2630525 | ||
|
|
306aff5ccf |
@@ -74,11 +74,22 @@ async function validateStartupConfig({ log, CADDYFILE_PATH, SERVICES_FILE, CONFI
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 3. Check if port is available
|
// 3. Check if port is available
|
||||||
|
// CRITICAL: listen() and close() are async. If we fire-and-forget both
|
||||||
|
// (the old code), the kernel hasn't released the port by the time
|
||||||
|
// app.listen(PORT) runs in server.js → EADDRINUSE → crash loop.
|
||||||
|
// Await both via Promises so the port is truly free before we return.
|
||||||
const net = require('net');
|
const net = require('net');
|
||||||
const portCheckServer = net.createServer();
|
const portCheckServer = net.createServer();
|
||||||
try {
|
try {
|
||||||
portCheckServer.listen(PORT, '0.0.0.0');
|
await new Promise((resolve, reject) => {
|
||||||
portCheckServer.close();
|
portCheckServer.once('error', reject);
|
||||||
|
portCheckServer.listen(PORT, '0.0.0.0', () => {
|
||||||
|
portCheckServer.close(() => {
|
||||||
|
portCheckServer.removeListener('error', reject);
|
||||||
|
resolve();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
log.info('startup', `Port ${PORT} is available`);
|
log.info('startup', `Port ${PORT} is available`);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
errors.push(`Port ${PORT} is already in use or cannot be bound`);
|
errors.push(`Port ${PORT} is already in use or cannot be bound`);
|
||||||
|
|||||||
@@ -136,7 +136,7 @@ else
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
docker run -d --restart unless-stopped --name ${CONTAINER_NAME} \
|
docker run -d --restart unless-stopped --name ${CONTAINER_NAME} \
|
||||||
--memory=512m --memory-swap=1g --cpus=1.5 \
|
--memory=1g --memory-swap=2g --cpus=2 \
|
||||||
--add-host=get.dashcaddy.net:194.233.88.206 \
|
--add-host=get.dashcaddy.net:194.233.88.206 \
|
||||||
--add-host=get2.dashcaddy.net:194.233.88.206 \
|
--add-host=get2.dashcaddy.net:194.233.88.206 \
|
||||||
--dns ${DNS_PRIMARY} \
|
--dns ${DNS_PRIMARY} \
|
||||||
|
|||||||
Reference in New Issue
Block a user