# SQUAWK cPanel deployment

This package contains a production Next.js build created with Webpack on macOS,
but excludes macOS native modules. It is designed to use the Linux
`node_modules` already installed by cPanel in:

`/home/rilelhpp/squawk/apps/squawk`

Do not upload a local `node_modules` folder. Do not run `next build` on the
server for this release.

## 1. Stop only the two abandoned build workers

The earlier failed builds left two orphan Next.js build workers using roughly
700 MB. Run this validation-and-terminate block in the cPanel Node environment:

```bash
for pid in 3055423 3055424; do
  ppid=$(ps -p "$pid" -o ppid= 2>/dev/null | tr -d ' ')
  command=$(ps -p "$pid" -o args= 2>/dev/null)

  if [ "$ppid" = "1" ]; then
    case "$command" in
      */home/rilelhpp/nodevenv/squawk/apps/squawk/24/lib/node_modules/next/dist/compiled/jest-worker/processChild.js)
        echo "Sending SIGTERM to validated orphan worker $pid"
        kill -TERM "$pid"
        ;;
      *)
        echo "Skipping $pid: command no longer matches the SQUAWK build worker"
        ;;
    esac
  elif [ -n "$ppid" ]; then
    echo "Skipping $pid: PPID is $ppid, not 1"
  else
    echo "PID $pid is no longer running"
  fi
done
```

Check the exact PIDs again:

```bash
ps -p 3055423,3055424 -o pid,ppid,etime,rss,args
```

If either validated worker remains, stop here and contact the host. Do not use
`kill -9`, and do not stop the `lsnode` Passenger application process.

## 2. Preserve the incomplete server build

```bash
cd /home/rilelhpp/squawk/apps/squawk

if [ -e .next ]; then
  backup=.next.failed-build-20260818
  if [ -e "$backup" ]; then
    echo "Backup target already exists: $backup" >&2
    return 1 2>/dev/null || exit 1
  fi
  mv -- .next "$backup"
fi
```

This is recoverable: the incomplete `.next` directory is renamed, not deleted.

## 3. Upload and extract

Upload `squawk-cpanel-deploy-2026-08-18.zip` into
`/home/rilelhpp/squawk/apps/squawk`, then extract its contents directly there.
The `.next`, `public`, and root files must appear directly inside the application
root—not inside another `squawk-cpanel-deploy-2026-08-18` directory.

Keep the existing Linux `node_modules` directory. This ZIP intentionally does
not contain one.

## 4. Configure cPanel

In **Setup Node.js App**, use:

- Application root: `squawk/apps/squawk`
- Application startup file: `server.cjs`
- Node.js version: the existing Node 24 environment
- Application mode: Production

Add these environment variables before restarting:

- `RESEND_API_KEY`: your live Resend API key
- `RESEND_WAITLIST_SEGMENT_ID`: the Resend segment used for waitlist contacts

`PORT` is assigned by cPanel automatically; do not hard-code it. The wrapper
uses that assigned port and binds to `0.0.0.0`.

`NEXT_PUBLIC_POSTHOG_PROJECT_TOKEN` and `NEXT_PUBLIC_POSTHOG_HOST` are public
build-time values. If analytics was not configured when this ZIP was built,
adding them only in cPanel will not alter the compiled browser bundle; rebuild
the deployment ZIP locally after setting them.

## 5. Restart and verify

Use **Restart Application** in cPanel, then check:

- <https://meetsquawk.com/>
- <https://meetsquawk.com/privacy>
- The hero waitlist form with an email address you can safely remove later
- The footer waitlist form

If startup fails, inspect the cPanel application log first. The expected startup
message is similar to:

`SQUAWK is listening on http://0.0.0.0:<assigned-port>`

The included build was locally verified with Node.js, and the waitlist endpoint
is expected to return `503` when the Resend variables are absent.
