@@ -79,6 +79,41 @@ export const run = (name: string, version: string) => {
7979 "file with queues to monitor"
8080 ) . conflicts ( "queues" )
8181 )
82+ // PostgreSQL backend options (BullMQ v6+)
83+ . addOption (
84+ new Option (
85+ "--pg-host [host]" ,
86+ "PostgreSQL host (enables PG backend instead of Redis)"
87+ )
88+ . env ( "PG_HOST" )
89+ . conflicts ( [ "uri" , "nodes" , "sentinels" ] )
90+ )
91+ . option (
92+ "--pg-port [port]" ,
93+ "PostgreSQL port [5432]" ,
94+ process . env . PG_PORT || "5432"
95+ )
96+ . option (
97+ "--pg-database [database]" ,
98+ "PostgreSQL database name" ,
99+ process . env . PG_DATABASE
100+ )
101+ . option (
102+ "--pg-user [user]" ,
103+ "PostgreSQL user" ,
104+ process . env . PG_USER
105+ )
106+ . option (
107+ "--pg-password [password]" ,
108+ "PostgreSQL password" ,
109+ process . env . PG_PASSWORD
110+ )
111+ . option (
112+ "--pg-schema [schema]" ,
113+ "PostgreSQL schema for BullMQ tables [bullmq]" ,
114+ process . env . PG_SCHEMA
115+ )
116+ . option ( "--pg-ssl" , "enable SSL for PostgreSQL connection" )
82117 . parse ( process . argv ) ;
83118
84119 const options = program . opts ( ) ;
@@ -105,6 +140,22 @@ export const run = (name: string, version: string) => {
105140 process . exit ( 1 ) ;
106141 }
107142
143+ // Validate PostgreSQL options when PG backend is selected
144+ if ( options . pgHost ) {
145+ if ( ! options . pgDatabase ) {
146+ console . error (
147+ red ( "ERROR: --pg-database is required when using PostgreSQL backend" )
148+ ) ;
149+ process . exit ( 1 ) ;
150+ }
151+ if ( ! options . pgUser ) {
152+ console . error (
153+ red ( "ERROR: --pg-user is required when using PostgreSQL backend" )
154+ ) ;
155+ process . exit ( 1 ) ;
156+ }
157+ }
158+
108159 const queueNames = options . queuesFile
109160 ? parseQueuesFile ( options . queuesFile )
110161 : options . queues
@@ -152,6 +203,17 @@ export const run = (name: string, version: string) => {
152203 team : options . team ,
153204 nodes : options . nodes ? options . nodes . split ( "," ) : undefined ,
154205 queueNames,
206+ pgOpts : options . pgHost
207+ ? {
208+ host : options . pgHost ,
209+ port : parseInt ( options . pgPort , 10 ) ,
210+ database : options . pgDatabase ,
211+ user : options . pgUser ,
212+ password : options . pgPassword ,
213+ schema : options . pgSchema ,
214+ ssl : options . pgSsl || false ,
215+ }
216+ : undefined ,
155217 } ) ;
156218 } ) ;
157219
0 commit comments