# Debugging Passenger Issues

## The Problem

Passenger keeps failing with generic error messages and we can't see the logs.

Most likely cause: **canvas** and **sharp** are native Node.js modules that require system libraries (Cairo, Pango, libvips, etc.). On shared hosting, these often fail to load.

## Quick Test: Identify the Issue

### Step 1: Upload Test File

Upload `app-test.js` to `/public_html/CompareKit/`

### Step 2: Change Startup File

In cPanel Node.js app settings:

1. Change **"Application startup file"** to: `app-test.js`
2. Click **"SAVE"**
3. Click **"RESTART"**

### Step 3: Visit Your Site

Go to: `https://kodepilot.com/CompareKit/`

**Expected Results:**

**If you see "CompareKit Test Page":**
- ✅ Passenger works fine
- ✅ Express works fine
- ❌ The problem is canvas/sharp native modules

**If you still see Passenger error:**
- ❌ Different issue (permissions, Node version, etc.)

### Step 4: Test Dependencies

Visit: `https://kodepilot.com/CompareKit/test-dependencies`

This will show which modules load successfully:
```json
{
  "express": "OK",
  "cors": "OK",
  "canvas": "FAILED: ...",
  "sharp": "FAILED: ..."
}
```

---

## Solution A: Canvas/Sharp Issue (Most Likely)

If the test page works but canvas/sharp fail, you have **3 options**:

### Option 1: Deploy Elsewhere (Easiest)

**Vercel, Railway, or Render** have pre-built support for canvas/sharp:

```bash
# Local terminal
cd /Users/rogzim/Projects/CompareKit
npm install -g vercel
vercel
```

5 minutes and it's live!

### Option 2: Contact Hosting Support

Ask them to install these system packages:
```
cairo
pango
libpng
libjpeg
giflib
librsvg
libvips
```

### Option 3: Use canvas-prebuilt (Alternative)

Try a pre-compiled canvas version:

1. SSH into your server
2. Run:
```bash
cd /home/ziro2006/public_html/CompareKit
npm uninstall canvas
npm install canvas-prebuilt
```

---

## Solution B: Permission/Path Issues

If even the test app doesn't work:

### Check File Permissions

All files should be `644`, directories `755`:

```bash
# In SSH:
cd /home/ziro2006/public_html/CompareKit
find . -type f -exec chmod 644 {} \;
find . -type d -exec chmod 755 {} \;
```

### Check .env File

Make sure `.env` exists and is readable:

```bash
ls -la /home/ziro2006/public_html/CompareKit/.env
```

Should show: `-rw-r--r--`

---

## Solution C: Try Different Approach

If nothing works with CloudLinux Node.js Selector:

### Option 1: Use PM2 (if you have SSH)

```bash
ssh into server
cd /home/ziro2006/public_html/CompareKit
npm install -g pm2
pm2 start app.js --name comparekit
pm2 save
```

Then create `.htaccess` to proxy to port 3000.

### Option 2: Deploy to Subdomain on VPS

If you have a VPS or can get one ($5/month), deploy there instead.

---

## What to Do Next

1. Upload `app-test.js`
2. Change startup file to `app-test.js`
3. Restart app
4. Visit site and `/test-dependencies`
5. Report back what you see!

This will tell us exactly what's failing.
