-
Notifications
You must be signed in to change notification settings - Fork 0
Add client-domain backup hosting #7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| CREATE TABLE IF NOT EXISTS "site_publications" ( | ||
| "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL, | ||
| "site_id" uuid NOT NULL REFERENCES "sites"("id") ON DELETE cascade, | ||
| "crawl_id" uuid NOT NULL REFERENCES "crawls"("id") ON DELETE cascade, | ||
| "status" varchar(50) DEFAULT 'pending' NOT NULL, | ||
| "r2_prefix" varchar(500) NOT NULL, | ||
| "file_count" integer, | ||
| "total_bytes" bigint, | ||
| "error_message" text, | ||
| "published_at" timestamp with time zone, | ||
| "created_at" timestamp with time zone DEFAULT now(), | ||
| "updated_at" timestamp with time zone DEFAULT now() | ||
| ); | ||
|
|
||
| CREATE TABLE IF NOT EXISTS "site_domains" ( | ||
| "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL, | ||
| "site_id" uuid NOT NULL REFERENCES "sites"("id") ON DELETE cascade, | ||
| "hostname" varchar(255) NOT NULL, | ||
| "status" varchar(50) DEFAULT 'pending_dns' NOT NULL, | ||
| "cname_target" varchar(255) NOT NULL, | ||
| "active_publication_id" uuid REFERENCES "site_publications"("id") ON DELETE set null, | ||
| "cloudflare_hostname_id" varchar(255), | ||
| "ownership_verification_name" varchar(255), | ||
| "ownership_verification_value" text, | ||
| "ssl_status" varchar(100), | ||
| "error_message" text, | ||
| "created_at" timestamp with time zone DEFAULT now(), | ||
| "updated_at" timestamp with time zone DEFAULT now() | ||
| ); | ||
|
|
||
| CREATE UNIQUE INDEX IF NOT EXISTS "site_domains_hostname_idx" ON "site_domains" ("hostname"); | ||
| CREATE INDEX IF NOT EXISTS "site_publications_site_id_idx" ON "site_publications" ("site_id"); | ||
| CREATE INDEX IF NOT EXISTS "site_domains_site_id_idx" ON "site_domains" ("site_id"); |
4 changes: 4 additions & 0 deletions
4
apps/api/src/db/migrations/0004_add_hosting_controls_and_billing.sql
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| ALTER TABLE "sites" ADD COLUMN IF NOT EXISTS "hosting_auto_publish" boolean DEFAULT true; | ||
| ALTER TABLE "sites" ADD COLUMN IF NOT EXISTS "hosting_billing_email" varchar(255); | ||
| ALTER TABLE "sites" ADD COLUMN IF NOT EXISTS "hosting_payment_link_url" varchar(1000); | ||
| ALTER TABLE "sites" ADD COLUMN IF NOT EXISTS "hosting_billing_status" varchar(50) DEFAULT 'not_sent'; |
2 changes: 2 additions & 0 deletions
2
apps/api/src/db/migrations/0005_add_hosting_redirect_mode.sql
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| ALTER TABLE "site_domains" ADD COLUMN IF NOT EXISTS "redirect_enabled" boolean DEFAULT false; | ||
| ALTER TABLE "site_domains" ADD COLUMN IF NOT EXISTS "redirect_target_origin" varchar(500); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reuse a single publication queue instance.
Creating a new BullMQ
Queueon everyaddPublicationJob()call adds avoidable Redis churn and can leak queue resources over time. This should be initialized once alongside the crawl queue and reused.♻️ Suggested fix
export function createNodeQueueClient(redisUrl: string): QueueClient { const redis = new Redis(redisUrl, { maxRetriesPerRequest: null }); const queue = new Queue("crawl-jobs", { connection: redis, @@ }); + const publicationQueue = new Queue("publication-jobs", { + connection: redis, + defaultJobOptions: { + removeOnComplete: 100, + removeOnFail: 100, + attempts: 1, + }, + }); return { @@ }, async addPublicationJob(siteId, crawlId, publicationId, activate, autoPublish) { - const publishQueue = new Queue("publication-jobs", { - connection: redis, - defaultJobOptions: { - removeOnComplete: 100, - removeOnFail: 100, - attempts: 1, - }, - }); - await publishQueue.add("publish", { siteId, crawlId, publicationId, activate, autoPublish: autoPublish ?? false }, { jobId: publicationId }); + await publicationQueue.add("publish", { siteId, crawlId, publicationId, activate, autoPublish: autoPublish ?? false }, { jobId: publicationId }); },🤖 Prompt for AI Agents