Remove Node.js placeholder server completely and use actual Museum server
This commit is contained in:
parent
fdbb6d9a7a
commit
2d68e44208
459
start.sh
459
start.sh
@ -143,307 +143,126 @@ else
|
|||||||
echo "==> PostgreSQL connection successful"
|
echo "==> PostgreSQL connection successful"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Create enhanced Node.js placeholder server
|
# Build or download Museum server
|
||||||
echo "==> Creating enhanced Node.js placeholder server..."
|
echo "==> Setting up Museum server..."
|
||||||
cat > /app/data/ente/server/server.js << 'EOF'
|
MUSEUM_BIN="/app/data/ente/server/museum"
|
||||||
const http = require('http');
|
|
||||||
const fs = require('fs');
|
|
||||||
const { promisify } = require('util');
|
|
||||||
const { execSync } = require('child_process');
|
|
||||||
const path = require('path');
|
|
||||||
|
|
||||||
const PORT = 3080;
|
# Check if the Museum binary already exists and is executable
|
||||||
const LOG_FILE = '/app/data/logs/museum.log';
|
if [ -f "$MUSEUM_BIN" ] && [ -x "$MUSEUM_BIN" ]; then
|
||||||
const DB_SCHEMA_FILE = '/app/data/ente/server/schema.sql';
|
echo "==> Museum server binary already exists, skipping build/download"
|
||||||
|
else
|
||||||
|
# Try to build Museum server from source
|
||||||
|
echo "==> Attempting to build Museum server from source..."
|
||||||
|
|
||||||
// Ensure log directory exists
|
# Check if Go is installed
|
||||||
if (!fs.existsSync('/app/data/logs')) {
|
if command -v go >/dev/null 2>&1; then
|
||||||
fs.mkdirSync('/app/data/logs', { recursive: true });
|
echo "==> Go is installed, building Museum server..."
|
||||||
}
|
|
||||||
|
|
||||||
// Log function
|
# Navigate to the server directory and build
|
||||||
function log(message) {
|
cd "$ENTE_DIR/server"
|
||||||
const timestamp = new Date().toISOString();
|
export GOPATH="/app/data/go"
|
||||||
const logMessage = `${timestamp} - ${message}\n`;
|
export PATH="$GOPATH/bin:$PATH"
|
||||||
console.log(logMessage);
|
|
||||||
try {
|
|
||||||
fs.appendFileSync(LOG_FILE, logMessage);
|
|
||||||
} catch (err) {
|
|
||||||
console.error(`Error writing to log: ${err.message}`);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
log('Starting enhanced Node.js placeholder server...');
|
# Install dependencies if needed
|
||||||
|
if command -v apt-get >/dev/null 2>&1; then
|
||||||
|
apt-get update && apt-get install -y gcc libsodium-dev pkg-config
|
||||||
|
fi
|
||||||
|
|
||||||
// Try to initialize the database schema
|
# Build the server
|
||||||
function initializeDatabase() {
|
go build -o "$MUSEUM_BIN" ./cmd/museum
|
||||||
try {
|
|
||||||
// Create a basic schema file if it doesn't exist
|
|
||||||
if (!fs.existsSync(DB_SCHEMA_FILE)) {
|
|
||||||
log('Creating basic database schema file');
|
|
||||||
const basicSchema = `
|
|
||||||
-- Basic schema for Ente Museum server
|
|
||||||
CREATE TABLE IF NOT EXISTS users (
|
|
||||||
id SERIAL PRIMARY KEY,
|
|
||||||
email VARCHAR(255) UNIQUE NOT NULL,
|
|
||||||
created_at TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP,
|
|
||||||
updated_at TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP
|
|
||||||
);
|
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS files (
|
if [ $? -eq 0 ] && [ -f "$MUSEUM_BIN" ] && [ -x "$MUSEUM_BIN" ]; then
|
||||||
id SERIAL PRIMARY KEY,
|
echo "==> Successfully built Museum server"
|
||||||
user_id INTEGER REFERENCES users(id),
|
else
|
||||||
filename VARCHAR(255) NOT NULL,
|
echo "==> Failed to build Museum server, will try to download pre-built binary"
|
||||||
path VARCHAR(255) NOT NULL,
|
|
||||||
created_at TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP,
|
|
||||||
updated_at TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP
|
|
||||||
);
|
|
||||||
`;
|
|
||||||
fs.writeFileSync(DB_SCHEMA_FILE, basicSchema);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Try to initialize the database
|
# Determine architecture for downloading
|
||||||
const dbUser = process.env.CLOUDRON_POSTGRESQL_USERNAME;
|
ARCH=$(uname -m)
|
||||||
const dbPassword = process.env.CLOUDRON_POSTGRESQL_PASSWORD;
|
OS=$(uname -s | tr '[:upper:]' '[:lower:]')
|
||||||
const dbHost = process.env.CLOUDRON_POSTGRESQL_HOST;
|
if [ "$ARCH" == "x86_64" ]; then ARCH="amd64"; fi
|
||||||
const dbPort = process.env.CLOUDRON_POSTGRESQL_PORT;
|
if [ "$ARCH" == "aarch64" ] || [ "$ARCH" == "arm64" ]; then ARCH="arm64"; fi
|
||||||
const dbName = process.env.CLOUDRON_POSTGRESQL_DATABASE;
|
|
||||||
|
|
||||||
if (dbUser && dbPassword && dbHost && dbPort && dbName) {
|
# Try to download from GitHub releases
|
||||||
log(`Initializing database ${dbName} on ${dbHost}:${dbPort}`);
|
echo "==> Downloading Museum server binary for ${OS}-${ARCH}..."
|
||||||
const command = `PGPASSWORD="${dbPassword}" psql -h "${dbHost}" -p "${dbPort}" -U "${dbUser}" -d "${dbName}" -f "${DB_SCHEMA_FILE}"`;
|
if ! curl -L -o "$MUSEUM_BIN" "https://github.com/ente-io/ente/releases/latest/download/museum-${OS}-${ARCH}"; then
|
||||||
execSync(command, { stdio: 'inherit' });
|
echo "==> Download failed, trying alternative URL..."
|
||||||
log('Database initialized successfully');
|
if ! curl -L -o "$MUSEUM_BIN" "https://github.com/ente-io/ente/releases/download/latest/museum-${OS}-${ARCH}"; then
|
||||||
return true;
|
echo "==> All download attempts failed"
|
||||||
} else {
|
|
||||||
log('Database environment variables not set, skipping initialization');
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
} catch (err) {
|
|
||||||
log(`Error initializing database: ${err.message}`);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Try to initialize database
|
# Return error and let the next section handle it
|
||||||
initializeDatabase();
|
false
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
// API response handlers
|
if [ -f "$MUSEUM_BIN" ]; then
|
||||||
const apiHandlers = {
|
chmod +x "$MUSEUM_BIN"
|
||||||
// Health check endpoint
|
echo "==> Successfully downloaded Museum server binary"
|
||||||
'/health': (req, res) => {
|
fi
|
||||||
res.writeHead(200, { 'Content-Type': 'application/json' });
|
fi
|
||||||
res.end(JSON.stringify({
|
else
|
||||||
status: 'OK',
|
echo "==> Go is not installed, downloading pre-built Museum server binary..."
|
||||||
server: 'Museum Placeholder',
|
|
||||||
version: '1.0.0'
|
|
||||||
}));
|
|
||||||
log('Health check request - responded with status OK');
|
|
||||||
},
|
|
||||||
|
|
||||||
// User verification endpoint
|
# Determine architecture for downloading
|
||||||
'/api/users/verify': (req, res) => {
|
ARCH=$(uname -m)
|
||||||
res.writeHead(200, { 'Content-Type': 'application/json' });
|
OS=$(uname -s | tr '[:upper:]' '[:lower:]')
|
||||||
log('User verify request - responding with success');
|
if [ "$ARCH" == "x86_64" ]; then ARCH="amd64"; fi
|
||||||
res.end(JSON.stringify({
|
if [ "$ARCH" == "aarch64" ] || [ "$ARCH" == "arm64" ]; then ARCH="arm64"; fi
|
||||||
success: true,
|
|
||||||
isValidEmail: true,
|
|
||||||
isAvailable: true,
|
|
||||||
isVerified: true,
|
|
||||||
canCreateAccount: true
|
|
||||||
}));
|
|
||||||
},
|
|
||||||
|
|
||||||
// User login endpoint
|
# Try to download from GitHub releases
|
||||||
'/api/users/login': (req, res) => {
|
echo "==> Downloading Museum server binary for ${OS}-${ARCH}..."
|
||||||
if (req.method === 'POST') {
|
if ! curl -L -o "$MUSEUM_BIN" "https://github.com/ente-io/ente/releases/latest/download/museum-${OS}-${ARCH}"; then
|
||||||
let body = '';
|
echo "==> Download failed, trying alternative URL..."
|
||||||
req.on('data', chunk => {
|
if ! curl -L -o "$MUSEUM_BIN" "https://github.com/ente-io/ente/releases/download/latest/museum-${OS}-${ARCH}"; then
|
||||||
body += chunk.toString();
|
echo "==> All download attempts failed"
|
||||||
});
|
|
||||||
req.on('end', () => {
|
|
||||||
log('Login request received');
|
|
||||||
res.writeHead(200, { 'Content-Type': 'application/json' });
|
|
||||||
res.end(JSON.stringify({
|
|
||||||
success: true,
|
|
||||||
token: 'placeholder-jwt-token',
|
|
||||||
user: {
|
|
||||||
id: 1,
|
|
||||||
email: 'placeholder@example.com',
|
|
||||||
name: 'Placeholder User'
|
|
||||||
}
|
|
||||||
}));
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
res.writeHead(405, { 'Content-Type': 'application/json' });
|
|
||||||
res.end(JSON.stringify({
|
|
||||||
success: false,
|
|
||||||
message: 'Method not allowed'
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
// User signup endpoint
|
# Create guide on setting up the server manually
|
||||||
'/api/users/signup': (req, res) => {
|
cat > /app/data/MANUAL-SETUP-REQUIRED.md << 'EOF'
|
||||||
if (req.method === 'POST') {
|
# Manual Setup Required
|
||||||
let body = '';
|
|
||||||
req.on('data', chunk => {
|
|
||||||
body += chunk.toString();
|
|
||||||
});
|
|
||||||
req.on('end', () => {
|
|
||||||
log('Signup request received');
|
|
||||||
res.writeHead(200, { 'Content-Type': 'application/json' });
|
|
||||||
res.end(JSON.stringify({
|
|
||||||
success: true,
|
|
||||||
token: 'placeholder-jwt-token',
|
|
||||||
user: {
|
|
||||||
id: 1,
|
|
||||||
email: 'placeholder@example.com',
|
|
||||||
name: 'New User'
|
|
||||||
}
|
|
||||||
}));
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
res.writeHead(405, { 'Content-Type': 'application/json' });
|
|
||||||
res.end(JSON.stringify({
|
|
||||||
success: false,
|
|
||||||
message: 'Method not allowed'
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
// Files endpoint
|
The automatic setup of the Museum server failed. Please follow these steps to set up the server manually:
|
||||||
'/api/files': (req, res) => {
|
|
||||||
res.writeHead(200, { 'Content-Type': 'application/json' });
|
|
||||||
log('Files request - responding with empty list');
|
|
||||||
res.end(JSON.stringify({
|
|
||||||
success: true,
|
|
||||||
files: []
|
|
||||||
}));
|
|
||||||
},
|
|
||||||
|
|
||||||
// Collections endpoint
|
1. Connect to your Cloudron server via SSH
|
||||||
'/api/collections': (req, res) => {
|
2. Download the Museum server binary manually using one of these methods:
|
||||||
res.writeHead(200, { 'Content-Type': 'application/json' });
|
|
||||||
log('Collections request - responding with empty list');
|
|
||||||
res.end(JSON.stringify({
|
|
||||||
success: true,
|
|
||||||
collections: []
|
|
||||||
}));
|
|
||||||
},
|
|
||||||
|
|
||||||
// Default API handler
|
```
|
||||||
'default': (req, res) => {
|
# Install Go and build from source
|
||||||
res.writeHead(200, { 'Content-Type': 'application/json' });
|
apt-get update && apt-get install -y golang-go gcc libsodium-dev pkg-config
|
||||||
log(`API request to ${req.url} - responding with generic success`);
|
cd /app/data/ente/repository/server
|
||||||
res.end(JSON.stringify({
|
export GOPATH="/app/data/go"
|
||||||
success: true,
|
export PATH="$GOPATH/bin:$PATH"
|
||||||
message: 'Placeholder API response',
|
go build -o /app/data/ente/server/museum ./cmd/museum
|
||||||
path: req.url
|
chmod +x /app/data/ente/server/museum
|
||||||
}));
|
```
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// Create server
|
Or download a pre-built binary if available:
|
||||||
const server = http.createServer((req, res) => {
|
|
||||||
log(`Request received: ${req.method} ${req.url}`);
|
|
||||||
|
|
||||||
// Set CORS headers for all responses
|
```
|
||||||
res.setHeader('Access-Control-Allow-Origin', '*');
|
# Determine architecture
|
||||||
res.setHeader('Access-Control-Allow-Methods', 'GET, POST, OPTIONS, PUT, PATCH, DELETE');
|
ARCH=$(uname -m)
|
||||||
res.setHeader('Access-Control-Allow-Headers', 'X-Requested-With,content-type,Authorization');
|
OS=$(uname -s | tr '[:upper:]' '[:lower:]')
|
||||||
|
if [ "$ARCH" == "x86_64" ]; then ARCH="amd64"; fi
|
||||||
|
if [ "$ARCH" == "aarch64" ] || [ "$ARCH" == "arm64" ]; then ARCH="arm64"; fi
|
||||||
|
|
||||||
// Handle OPTIONS request (for CORS preflight)
|
# Try to download from GitHub releases
|
||||||
if (req.method === 'OPTIONS') {
|
curl -L -o /app/data/ente/server/museum "https://github.com/ente-io/ente/releases/latest/download/museum-${OS}-${ARCH}"
|
||||||
res.writeHead(200);
|
chmod +x /app/data/ente/server/museum
|
||||||
res.end();
|
```
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check if there's a specific handler for this path
|
3. Restart the Ente app in your Cloudron dashboard
|
||||||
const handler = apiHandlers[req.url] || apiHandlers['default'];
|
|
||||||
|
|
||||||
// Handle paths that exactly match defined endpoints
|
|
||||||
if (apiHandlers[req.url]) {
|
|
||||||
handler(req, res);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Handle health check endpoint
|
|
||||||
if (req.url === '/api/health') {
|
|
||||||
apiHandlers['/health'](req, res);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Route based on URL pattern
|
|
||||||
if (req.url.startsWith('/api/')) {
|
|
||||||
handler(req, res);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Default response for any other endpoint
|
|
||||||
res.writeHead(200, { 'Content-Type': 'application/json' });
|
|
||||||
log(`Unknown request to ${req.url} - responding with default message`);
|
|
||||||
res.end(JSON.stringify({
|
|
||||||
message: 'Ente Placeholder Server',
|
|
||||||
path: req.url,
|
|
||||||
server: 'Node.js Placeholder'
|
|
||||||
}));
|
|
||||||
});
|
|
||||||
|
|
||||||
// Start server
|
|
||||||
try {
|
|
||||||
server.listen(PORT, '0.0.0.0', () => {
|
|
||||||
log(`Museum placeholder server running on port ${PORT}`);
|
|
||||||
log(`Server is listening at http://0.0.0.0:${PORT}`);
|
|
||||||
});
|
|
||||||
} catch (err) {
|
|
||||||
log(`Failed to start server: ${err.message}`);
|
|
||||||
process.exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Handle errors
|
|
||||||
server.on('error', (error) => {
|
|
||||||
log(`Server error: ${error.message}`);
|
|
||||||
if (error.code === 'EADDRINUSE') {
|
|
||||||
log('Address already in use, retrying in 5 seconds...');
|
|
||||||
setTimeout(() => {
|
|
||||||
server.close();
|
|
||||||
server.listen(PORT, '0.0.0.0');
|
|
||||||
}, 5000);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// Log startup
|
|
||||||
log('Enhanced Museum placeholder server initialization complete');
|
|
||||||
EOF
|
EOF
|
||||||
echo "==> Created enhanced Node.js placeholder server"
|
echo "==> Created guide for manual setup"
|
||||||
|
|
||||||
# Start the Node.js placeholder server
|
# Continue and rely on Caddy to serve static files
|
||||||
echo "==> Starting Node.js placeholder server..."
|
echo "==> The application will run with limited functionality without the Museum server"
|
||||||
cd /app/data/ente/server
|
fi
|
||||||
node server.js > /app/data/logs/museum.log 2>&1 &
|
fi
|
||||||
SERVER_PID=$!
|
|
||||||
echo "==> Started Node.js server with PID: $SERVER_PID"
|
|
||||||
|
|
||||||
# Wait for server to start
|
if [ -f "$MUSEUM_BIN" ]; then
|
||||||
MAX_ATTEMPTS=30
|
chmod +x "$MUSEUM_BIN"
|
||||||
ATTEMPT=0
|
echo "==> Successfully downloaded Museum server binary"
|
||||||
while [ $ATTEMPT -lt $MAX_ATTEMPTS ]; do
|
fi
|
||||||
if curl -s http://localhost:3080/health > /dev/null; then
|
|
||||||
echo "==> Node.js placeholder server started successfully"
|
|
||||||
break
|
|
||||||
fi
|
fi
|
||||||
ATTEMPT=$((ATTEMPT+1))
|
|
||||||
echo "==> Waiting for Node.js server to start (attempt $ATTEMPT/$MAX_ATTEMPTS)..."
|
|
||||||
sleep 1
|
|
||||||
done
|
|
||||||
|
|
||||||
if [ $ATTEMPT -eq $MAX_ATTEMPTS ]; then
|
|
||||||
echo "==> ERROR: Node.js server failed to start within $MAX_ATTEMPTS seconds"
|
|
||||||
echo "==> Last few lines of museum.log:"
|
|
||||||
tail -n 20 /app/data/logs/museum.log || echo "==> No log file found"
|
|
||||||
exit 1
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Download and set up web app
|
# Download and set up web app
|
||||||
@ -467,6 +286,7 @@ if [ ! -d "${WEB_DIR}/photos" ] || [ ! -f "${WEB_DIR}/photos/index.html" ]; then
|
|||||||
p { color: #666; }
|
p { color: #666; }
|
||||||
.alert { background-color: #f8f9fa; border-left: 4px solid #5cb85c; padding: 15px; margin-bottom: 20px; }
|
.alert { background-color: #f8f9fa; border-left: 4px solid #5cb85c; padding: 15px; margin-bottom: 20px; }
|
||||||
.alert-info { border-color: #2196F3; }
|
.alert-info { border-color: #2196F3; }
|
||||||
|
.alert-warning { border-color: #ff9800; }
|
||||||
.setup-box { background-color: #f5f5f5; padding: 20px; border-radius: 5px; margin-top: 20px; text-align: left; }
|
.setup-box { background-color: #f5f5f5; padding: 20px; border-radius: 5px; margin-top: 20px; text-align: left; }
|
||||||
code { background-color: #f1f1f1; padding: 2px 5px; border-radius: 3px; font-family: monospace; }
|
code { background-color: #f1f1f1; padding: 2px 5px; border-radius: 3px; font-family: monospace; }
|
||||||
</style>
|
</style>
|
||||||
@ -475,13 +295,13 @@ if [ ! -d "${WEB_DIR}/photos" ] || [ ! -f "${WEB_DIR}/photos/index.html" ]; then
|
|||||||
<div class="container">
|
<div class="container">
|
||||||
<h1>Ente Photos</h1>
|
<h1>Ente Photos</h1>
|
||||||
<div class="alert alert-info">
|
<div class="alert alert-info">
|
||||||
<strong>Status:</strong> Running with placeholder server. Most functionality will be limited until the actual Museum server is running.
|
<strong>Status:</strong> Ente is being set up. Check logs for details.
|
||||||
</div>
|
</div>
|
||||||
<p>This is the Ente Photos application running on Cloudron. To complete the setup, you need to:</p>
|
<p>This is the Ente Photos application running on Cloudron. To complete the setup, you need to:</p>
|
||||||
<div class="setup-box">
|
<div class="setup-box">
|
||||||
<ol>
|
<ol>
|
||||||
<li>Configure your S3 storage in <code>/app/data/s3.env</code></li>
|
<li>Configure your S3 storage in <code>/app/data/s3.env</code></li>
|
||||||
<li>The placeholder server is handling API requests for now</li>
|
<li>Ensure the Museum server is running</li>
|
||||||
<li>Visit <a href="/photos/">the photos app</a> to start using your self-hosted Ente instance</li>
|
<li>Visit <a href="/photos/">the photos app</a> to start using your self-hosted Ente instance</li>
|
||||||
</ol>
|
</ol>
|
||||||
</div>
|
</div>
|
||||||
@ -503,7 +323,7 @@ EOF
|
|||||||
cp ${WEB_DIR}/photos/index.html ${WEB_DIR}/cast/index.html
|
cp ${WEB_DIR}/photos/index.html ${WEB_DIR}/cast/index.html
|
||||||
sed -i 's/Photos/Cast/g' ${WEB_DIR}/cast/index.html
|
sed -i 's/Photos/Cast/g' ${WEB_DIR}/cast/index.html
|
||||||
|
|
||||||
echo "==> Created improved placeholder HTML files"
|
echo "==> Created placeholder HTML files"
|
||||||
else
|
else
|
||||||
echo "==> Ente web app already set up"
|
echo "==> Ente web app already set up"
|
||||||
fi
|
fi
|
||||||
@ -543,6 +363,38 @@ EOF
|
|||||||
echo "==> Created runtime config for ${APP}"
|
echo "==> Created runtime config for ${APP}"
|
||||||
done
|
done
|
||||||
|
|
||||||
|
# Start Museum server if binary exists and is executable
|
||||||
|
if [ -f "$MUSEUM_BIN" ] && [ -x "$MUSEUM_BIN" ]; then
|
||||||
|
echo "==> Starting Museum server..."
|
||||||
|
cd /app/data/ente/server
|
||||||
|
"$MUSEUM_BIN" --config "$MUSEUM_CONFIG" > /app/data/logs/museum.log 2>&1 &
|
||||||
|
MUSEUM_PID=$!
|
||||||
|
echo "==> Started Museum server with PID: $MUSEUM_PID"
|
||||||
|
|
||||||
|
# Wait for server to start
|
||||||
|
MAX_ATTEMPTS=30
|
||||||
|
ATTEMPT=0
|
||||||
|
while [ $ATTEMPT -lt $MAX_ATTEMPTS ]; do
|
||||||
|
if curl -s http://localhost:3080/health > /dev/null; then
|
||||||
|
echo "==> Museum server started successfully"
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
ATTEMPT=$((ATTEMPT+1))
|
||||||
|
echo "==> Waiting for Museum server to start (attempt $ATTEMPT/$MAX_ATTEMPTS)..."
|
||||||
|
sleep 1
|
||||||
|
done
|
||||||
|
|
||||||
|
if [ $ATTEMPT -eq $MAX_ATTEMPTS ]; then
|
||||||
|
echo "==> ERROR: Museum server failed to start within $MAX_ATTEMPTS seconds"
|
||||||
|
echo "==> Last few lines of museum.log:"
|
||||||
|
tail -n 20 /app/data/logs/museum.log || echo "==> No log file found"
|
||||||
|
echo "==> Will continue with limited functionality"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo "==> WARNING: Museum server binary not found or not executable"
|
||||||
|
echo "==> The application will run with limited functionality"
|
||||||
|
fi
|
||||||
|
|
||||||
# Set up Caddy web server
|
# Set up Caddy web server
|
||||||
echo "==> Setting up Caddy web server..."
|
echo "==> Setting up Caddy web server..."
|
||||||
cat > /app/data/Caddyfile << EOF
|
cat > /app/data/Caddyfile << EOF
|
||||||
@ -561,6 +413,11 @@ cat > /app/data/Caddyfile << EOF
|
|||||||
reverse_proxy localhost:3080
|
reverse_proxy localhost:3080
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Health check endpoint
|
||||||
|
handle /health {
|
||||||
|
reverse_proxy localhost:3080
|
||||||
|
}
|
||||||
|
|
||||||
# Static web apps
|
# Static web apps
|
||||||
handle /photos/* {
|
handle /photos/* {
|
||||||
root * /app/data/web/photos
|
root * /app/data/web/photos
|
||||||
@ -600,54 +457,14 @@ caddy run --config /app/data/Caddyfile > /app/data/logs/caddy.log 2>&1 &
|
|||||||
CADDY_PID=$!
|
CADDY_PID=$!
|
||||||
echo "==> Caddy web server started with PID: $CADDY_PID"
|
echo "==> Caddy web server started with PID: $CADDY_PID"
|
||||||
|
|
||||||
# Create a small message to explain how to install the real Museum server
|
|
||||||
cat > /app/data/INSTALL-REAL-SERVER.md << 'EOF'
|
|
||||||
# Installing the Real Museum Server
|
|
||||||
|
|
||||||
The placeholder Node.js server is currently running. To install the real Museum server,
|
|
||||||
follow these steps:
|
|
||||||
|
|
||||||
1. Connect to your Cloudron server via SSH
|
|
||||||
2. Download the Museum server binary manually using one of these methods:
|
|
||||||
|
|
||||||
```
|
|
||||||
# Install Go and build from source
|
|
||||||
apt-get update && apt-get install -y golang-go gcc libsodium-dev pkg-config
|
|
||||||
cd /app/data/ente/repository/server
|
|
||||||
export GOPATH="/app/data/go"
|
|
||||||
export PATH="$GOPATH/bin:$PATH"
|
|
||||||
go build -o /app/data/ente/server/museum ./cmd/museum
|
|
||||||
chmod +x /app/data/ente/server/museum
|
|
||||||
```
|
|
||||||
|
|
||||||
Or download a pre-built binary if available:
|
|
||||||
|
|
||||||
```
|
|
||||||
# Determine architecture
|
|
||||||
ARCH=$(uname -m)
|
|
||||||
OS=$(uname -s | tr '[:upper:]' '[:lower:]')
|
|
||||||
if [ "$ARCH" == "x86_64" ]; then ARCH="amd64"; fi
|
|
||||||
if [ "$ARCH" == "aarch64" ] || [ "$ARCH" == "arm64" ]; then ARCH="arm64"; fi
|
|
||||||
|
|
||||||
# Try to download from GitHub releases
|
|
||||||
curl -L -o /app/data/ente/server/museum "https://github.com/ente-io/ente/releases/latest/download/museum-${OS}-${ARCH}"
|
|
||||||
chmod +x /app/data/ente/server/museum
|
|
||||||
```
|
|
||||||
|
|
||||||
3. Restart the Ente app in your Cloudron dashboard
|
|
||||||
4. The script should now use the real Museum server instead of the placeholder
|
|
||||||
|
|
||||||
EOF
|
|
||||||
echo "==> Created installation guide for real Museum server"
|
|
||||||
|
|
||||||
# Remove the flag file to indicate that we've started successfully
|
# Remove the flag file to indicate that we've started successfully
|
||||||
rm -f /app/data/startup_in_progress
|
rm -f /app/data/startup_in_progress
|
||||||
echo "==> Setup complete, everything is running."
|
echo "==> Setup complete, everything is running."
|
||||||
|
|
||||||
# Verify services are running
|
# Verify services are running
|
||||||
echo "==> Verifying services..."
|
echo "==> Verifying services..."
|
||||||
ps aux | grep "node\|museum" | grep -v grep || echo "WARNING: No server running!"
|
ps aux | grep -E "museum" | grep -v grep && echo "==> Museum server is running" || echo "==> WARNING: Museum server is not running!"
|
||||||
ps aux | grep caddy | grep -v grep || echo "WARNING: Caddy server not running!"
|
ps aux | grep caddy | grep -v grep && echo "==> Caddy server is running" || echo "==> WARNING: Caddy server not running!"
|
||||||
|
|
||||||
# Keep script running
|
# Keep script running
|
||||||
echo "==> Entering wait loop to keep container alive..."
|
echo "==> Entering wait loop to keep container alive..."
|
||||||
|
Loading…
x
Reference in New Issue
Block a user