File tree 3 files changed +18
-7
lines changed
3 files changed +18
-7
lines changed Original file line number Diff line number Diff line change 1
1
require ( 'dotenv' ) . config ( ) ;
2
2
const { start } = require ( './bot' ) ;
3
3
const mongoConnect = require ( './db_connect' ) ;
4
+ const { resubscribeInvoices } = require ( './ln' ) ;
4
5
5
- process . on ( 'unhandledRejection' , e => { console . log ( e ) ; } ) ;
6
+ ( async ( ) => {
7
+ process . on ( 'unhandledRejection' , e => { console . log ( e ) ; } ) ;
6
8
7
- process . on ( 'uncaughtException' , e => { console . log ( e ) ; } ) ;
9
+ process . on ( 'uncaughtException' , e => { console . log ( e ) ; } ) ;
8
10
9
- mongoConnect ( ) ;
10
- start ( process . env . BOT_TOKEN ) ;
11
+ mongoose = mongoConnect ( ) ;
12
+ mongoose . connection
13
+ . once ( 'open' , async ( ) => {
14
+ console . log ( 'Connected to Mongo instance.' ) ;
15
+ const bot = start ( process . env . BOT_TOKEN ) ;
16
+ await resubscribeInvoices ( bot ) ;
17
+ } )
18
+ . on ( 'error' , error => console . log ( 'Error connecting to Mongo:' , error ) )
19
+ } ) ( ) ;
Original file line number Diff line number Diff line change @@ -722,9 +722,13 @@ const start = (botToken) => {
722
722
723
723
bot . launch ( ) ;
724
724
725
+ console . log ( 'Bot launched.' ) ;
726
+
725
727
// Enable graceful stop
726
728
process . once ( 'SIGINT' , ( ) => bot . stop ( 'SIGINT' ) ) ;
727
729
process . once ( 'SIGTERM' , ( ) => bot . stop ( 'SIGTERM' ) ) ;
730
+
731
+ return bot ;
728
732
} ;
729
733
730
734
module . exports = { initialize, start } ;
Original file line number Diff line number Diff line change @@ -12,9 +12,7 @@ const connect = () => {
12
12
useNewUrlParser : true ,
13
13
useUnifiedTopology : true ,
14
14
} ) ;
15
- mongoose . connection
16
- . once ( 'open' , ( ) => console . log ( 'Connected to Mongo instance.' ) )
17
- . on ( 'error' , error => console . log ( 'Error connecting to Mongo:' , error ) ) ;
15
+ return mongoose
18
16
} ;
19
17
20
18
module . exports = connect ;
You can’t perform that action at this time.
0 commit comments