debug 3
This commit is contained in:
parent
89373c84f8
commit
f3e87f2b9c
1
my-favorites-app/Procfile
Normal file
1
my-favorites-app/Procfile
Normal file
@ -0,0 +1 @@
|
|||||||
|
web: npm start
|
||||||
@ -17,6 +17,7 @@
|
|||||||
"class-variance-authority": "^0.7.0",
|
"class-variance-authority": "^0.7.0",
|
||||||
"clsx": "^2.1.0",
|
"clsx": "^2.1.0",
|
||||||
"date-fns": "^3.3.1",
|
"date-fns": "^3.3.1",
|
||||||
|
"express": "^4.18.2",
|
||||||
"lucide-react": "^0.358.0",
|
"lucide-react": "^0.358.0",
|
||||||
"next": "14.1.0",
|
"next": "14.1.0",
|
||||||
"react": "^18.2.0",
|
"react": "^18.2.0",
|
||||||
|
|||||||
@ -1,39 +1,66 @@
|
|||||||
const { createServer } = require('http');
|
// Simple Express server for more reliable deployment
|
||||||
const { parse } = require('url');
|
const express = require('express');
|
||||||
const next = require('next');
|
const next = require('next');
|
||||||
|
const path = require('path');
|
||||||
|
|
||||||
|
// Set up environment variables with defaults
|
||||||
const dev = process.env.NODE_ENV !== 'production';
|
const dev = process.env.NODE_ENV !== 'production';
|
||||||
const hostname = process.env.HOSTNAME || '0.0.0.0';
|
|
||||||
const port = parseInt(process.env.PORT || '3000', 10);
|
const port = parseInt(process.env.PORT || '3000', 10);
|
||||||
|
|
||||||
// Prepare the Next.js app
|
// Create the Next.js app instance with minimal configuration
|
||||||
const app = next({ dev, hostname, port });
|
const app = next({ dev });
|
||||||
const handle = app.getRequestHandler();
|
const handle = app.getRequestHandler();
|
||||||
|
|
||||||
app.prepare().then(() => {
|
// Log memory usage for debugging
|
||||||
console.log(`Next.js App is preparing to start...`);
|
const logMemoryUsage = () => {
|
||||||
|
const memoryUsage = process.memoryUsage();
|
||||||
|
console.log('Memory usage:');
|
||||||
|
console.log(` RSS: ${Math.round(memoryUsage.rss / 1024 / 1024)} MB`);
|
||||||
|
console.log(` Heap total: ${Math.round(memoryUsage.heapTotal / 1024 / 1024)} MB`);
|
||||||
|
console.log(` Heap used: ${Math.round(memoryUsage.heapUsed / 1024 / 1024)} MB`);
|
||||||
|
};
|
||||||
|
|
||||||
createServer(async (req, res) => {
|
// Handle uncaught exceptions
|
||||||
try {
|
process.on('uncaughtException', (err) => {
|
||||||
// Parse the URL
|
console.error('Uncaught exception:', err);
|
||||||
const parsedUrl = parse(req.url, true);
|
logMemoryUsage();
|
||||||
|
|
||||||
// Let Next.js handle the request
|
|
||||||
await handle(req, res, parsedUrl);
|
|
||||||
} catch (err) {
|
|
||||||
console.error('Error occurred handling request:', err);
|
|
||||||
res.statusCode = 500;
|
|
||||||
res.end('Internal Server Error');
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.once('error', (err) => {
|
|
||||||
console.error('Server error:', err);
|
|
||||||
process.exit(1);
|
|
||||||
})
|
|
||||||
.listen(port, hostname, () => {
|
|
||||||
console.log(`> Ready on http://${hostname}:${port}`);
|
|
||||||
});
|
|
||||||
}).catch((err) => {
|
|
||||||
console.error('Next.js app preparation failed:', err);
|
|
||||||
process.exit(1);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
process.on('unhandledRejection', (reason, promise) => {
|
||||||
|
console.error('Unhandled Rejection at:', promise, 'reason:', reason);
|
||||||
|
logMemoryUsage();
|
||||||
|
});
|
||||||
|
|
||||||
|
// Simple health check response
|
||||||
|
const healthCheck = (req, res) => {
|
||||||
|
res.status(200).json({ status: 'ok', timestamp: new Date().toISOString() });
|
||||||
|
};
|
||||||
|
|
||||||
|
app.prepare()
|
||||||
|
.then(() => {
|
||||||
|
const server = express();
|
||||||
|
|
||||||
|
// Add health check endpoint
|
||||||
|
server.get('/health', healthCheck);
|
||||||
|
server.get('/api/health', healthCheck);
|
||||||
|
|
||||||
|
// Serve static files from the public directory
|
||||||
|
server.use(express.static(path.join(__dirname, 'public')));
|
||||||
|
|
||||||
|
// Let Next.js handle all other routes
|
||||||
|
server.all('*', (req, res) => {
|
||||||
|
return handle(req, res);
|
||||||
|
});
|
||||||
|
|
||||||
|
// Start the server
|
||||||
|
server.listen(port, '0.0.0.0', (err) => {
|
||||||
|
if (err) throw err;
|
||||||
|
console.log(`> Ready on port ${port} - env ${process.env.NODE_ENV || 'development'}`);
|
||||||
|
logMemoryUsage();
|
||||||
|
});
|
||||||
|
})
|
||||||
|
.catch((ex) => {
|
||||||
|
console.error('An error occurred starting the app:', ex);
|
||||||
|
logMemoryUsage();
|
||||||
|
process.exit(1);
|
||||||
|
});
|
||||||
|
|||||||
45
my-favorites-app/src/app/index.html
Normal file
45
my-favorites-app/src/app/index.html
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>My Favorites - Maintenance</title>
|
||||||
|
<style>
|
||||||
|
body {
|
||||||
|
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
|
||||||
|
background-color: #f5f5f0;
|
||||||
|
color: #333;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
height: 100vh;
|
||||||
|
margin: 0;
|
||||||
|
padding: 20px;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
.container {
|
||||||
|
max-width: 600px;
|
||||||
|
padding: 40px;
|
||||||
|
background-color: white;
|
||||||
|
border-radius: 8px;
|
||||||
|
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
|
||||||
|
}
|
||||||
|
h1 {
|
||||||
|
color: #3b82f6;
|
||||||
|
margin-bottom: 16px;
|
||||||
|
}
|
||||||
|
p {
|
||||||
|
line-height: 1.6;
|
||||||
|
margin-bottom: 24px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div class="container">
|
||||||
|
<h1>My Favorites</h1>
|
||||||
|
<p>Our application is currently undergoing maintenance. We'll be back shortly with a collection of books, movies, series, and more that have made an impression.</p>
|
||||||
|
<p>Thank you for your patience!</p>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@ -1,16 +1,11 @@
|
|||||||
import type { Metadata } from "next";
|
import type { Metadata } from "next";
|
||||||
import { Geist, Geist_Mono } from "next/font/google";
|
import { Inter } from "next/font/google";
|
||||||
import { Header } from "@/components/Header";
|
|
||||||
import "./globals.css";
|
import "./globals.css";
|
||||||
|
|
||||||
const geistSans = Geist({
|
// Use Inter font instead of Geist for better compatibility
|
||||||
variable: "--font-geist-sans",
|
const inter = Inter({
|
||||||
subsets: ["latin"],
|
|
||||||
});
|
|
||||||
|
|
||||||
const geistMono = Geist_Mono({
|
|
||||||
variable: "--font-geist-mono",
|
|
||||||
subsets: ["latin"],
|
subsets: ["latin"],
|
||||||
|
display: "swap",
|
||||||
});
|
});
|
||||||
|
|
||||||
export const metadata: Metadata = {
|
export const metadata: Metadata = {
|
||||||
@ -25,11 +20,22 @@ export default function RootLayout({
|
|||||||
}>) {
|
}>) {
|
||||||
return (
|
return (
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
<body
|
<body className={`${inter.className} antialiased min-h-screen bg-background`}>
|
||||||
className={`${geistSans.variable} ${geistMono.variable} antialiased min-h-screen bg-background`}
|
|
||||||
>
|
|
||||||
<div className="relative flex min-h-screen flex-col">
|
<div className="relative flex min-h-screen flex-col">
|
||||||
<Header />
|
<header className="sticky top-0 z-50 w-full border-b bg-background/95 backdrop-blur">
|
||||||
|
<div className="container flex h-16 items-center">
|
||||||
|
<div className="mr-4 flex">
|
||||||
|
<a href="/" className="flex items-center space-x-2">
|
||||||
|
<span className="text-xl font-bold">My Favorites</span>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
<div className="flex flex-1 items-center justify-end">
|
||||||
|
<nav className="flex items-center space-x-2">
|
||||||
|
<a href="/admin" className="px-4 py-2 text-sm font-medium hover:underline">Admin</a>
|
||||||
|
</nav>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</header>
|
||||||
<main className="flex-1">
|
<main className="flex-1">
|
||||||
<div className="container py-6 md:py-10">
|
<div className="container py-6 md:py-10">
|
||||||
{children}
|
{children}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user