File tree Expand file tree Collapse file tree 13 files changed +430
-152
lines changed Expand file tree Collapse file tree 13 files changed +430
-152
lines changed Original file line number Diff line number Diff line change @@ -19,9 +19,9 @@ The process for adding features to this project is described in
19
19
20
20
## Local development setup
21
21
22
- ### Prerequistites
22
+ ### Prerequisites
23
23
24
- * NodeJS > v20 .x
24
+ * NodeJS > v22 .x
25
25
* A postgres DB running and/or docker installed
26
26
27
27
### Install dependencies
@@ -144,7 +144,7 @@ This file is ignored in the `.gitignore` file and should not be checked in to th
144
144
npm start
145
145
146
146
# running the app with dotenv-cli
147
- dotenv -e .env npm start
147
+ npx dotenv -e .env npm start
148
148
```
149
149
150
150
## Configuration
Load Diff This file was deleted.
Load Diff This file was deleted.
Load Diff This file was deleted.
Load Diff This file was deleted.
Original file line number Diff line number Diff line change
1
+ if ( process . env . NODE_ENV !== "production" ) {
2
+ require ( "dotenv" ) . config ( ) ;
3
+ }
4
+
5
+ if ( process . env . NEW_RELIC_APP_NAME ) {
6
+ require ( "newrelic" ) ;
7
+ }
8
+
9
+ const logger = require ( "../src/logger" ) . initialize ( ) ;
10
+ logger . info ( "===================================" ) ;
11
+ logger . info ( "=== STARTING ANALYTICS-REPORTER ===" ) ;
12
+ logger . info ( " Running /deploy/publisher.js" ) ;
13
+ logger . info ( "===================================" ) ;
14
+
15
+ // Job Scheduler
16
+ const Bree = require ( "bree" ) ;
17
+ const bree = new Bree ( {
18
+ logger,
19
+ jobs : [
20
+ // Runs `../jobs/realtime.js` 1 millisecond after the process starts and
21
+ // then every 15 minutes going forward.
22
+ {
23
+ name : "realtime" ,
24
+ timeout : "1" ,
25
+ interval : "15m" ,
26
+ } ,
27
+ // Runs `../jobs/daily.js` 1 minute after the process starts and then at
28
+ // 10:01 AM every day going forward.
29
+ {
30
+ name : "daily" ,
31
+ timeout : "1m" ,
32
+ interval : "at 10:01 am" ,
33
+ } ,
34
+ // Runs `../jobs/api.js` 2 minutes after the process starts and then at
35
+ // 10:02 AM every day going forward.
36
+ {
37
+ name : "api" ,
38
+ timeout : "2m" ,
39
+ interval : "at 10:02 am" ,
40
+ } ,
41
+ ] ,
42
+ } ) ;
43
+
44
+ ( async ( ) => {
45
+ await bree . start ( ) ;
46
+ } ) ( ) ;
Load Diff This file was deleted.
Original file line number Diff line number Diff line change
1
+ process . env . ANALYTICS_REPORTS_PATH = "reports/api.json" ;
2
+ process . env . ANALYTICS_SCRIPT_NAME = "api.js" ;
3
+
4
+ const { runQueuePublish } = require ( "../index.js" ) ;
5
+ const options = {
6
+ frequency : "daily" ,
7
+ debug : true ,
8
+ "write-to-database" : true ,
9
+ agenciesFile : `${ process . env . ANALYTICS_ROOT_PATH } /deploy/agencies.json` ,
10
+ } ;
11
+ const logger = require ( "../src/logger.js" ) . initialize ( ) ;
12
+
13
+ ( async ( ) => {
14
+ logger . info ( `Beginning job: ${ process . env . ANALYTICS_SCRIPT_NAME } ` ) ;
15
+
16
+ try {
17
+ await runQueuePublish ( options ) ;
18
+ logger . info ( `Job completed: ${ process . env . ANALYTICS_SCRIPT_NAME } ` ) ;
19
+ } catch ( e ) {
20
+ logger . error ( `Job exited with error: ${ process . env . ANALYTICS_SCRIPT_NAME } ` ) ;
21
+ logger . error ( e ) ;
22
+ throw e ;
23
+ }
24
+ } ) ( ) ;
Original file line number Diff line number Diff line change
1
+ process . env . ANALYTICS_REPORTS_PATH = "reports/usa.json" ;
2
+ process . env . ANALYTICS_SCRIPT_NAME = "daily.js" ;
3
+
4
+ const { runQueuePublish } = require ( "../index.js" ) ;
5
+ const options = {
6
+ publish : true ,
7
+ frequency : "daily" ,
8
+ slim : true ,
9
+ debug : true ,
10
+ csv : true ,
11
+ json : true ,
12
+ agenciesFile : `${ process . env . ANALYTICS_ROOT_PATH } /deploy/agencies.json` ,
13
+ } ;
14
+ const logger = require ( "../src/logger.js" ) . initialize ( ) ;
15
+
16
+ ( async ( ) => {
17
+ logger . info ( `Beginning job: ${ process . env . ANALYTICS_SCRIPT_NAME } ` ) ;
18
+
19
+ try {
20
+ await runQueuePublish ( options ) ;
21
+ logger . info ( `Job completed: ${ process . env . ANALYTICS_SCRIPT_NAME } ` ) ;
22
+ } catch ( e ) {
23
+ logger . error ( `Job exited with error: ${ process . env . ANALYTICS_SCRIPT_NAME } ` ) ;
24
+ logger . error ( e ) ;
25
+ throw e ;
26
+ }
27
+ } ) ( ) ;
Original file line number Diff line number Diff line change
1
+ process . env . ANALYTICS_REPORTS_PATH = "reports/usa.json" ;
2
+ process . env . ANALYTICS_SCRIPT_NAME = "realtime.js" ;
3
+
4
+ const { runQueuePublish } = require ( "../index.js" ) ;
5
+ const options = {
6
+ publish : true ,
7
+ frequency : "realtime" ,
8
+ slim : true ,
9
+ debug : true ,
10
+ csv : true ,
11
+ json : true ,
12
+ agenciesFile : `${ process . env . ANALYTICS_ROOT_PATH } /deploy/agencies.json` ,
13
+ } ;
14
+ const logger = require ( "../src/logger.js" ) . initialize ( ) ;
15
+
16
+ ( async ( ) => {
17
+ logger . info ( `Beginning job: ${ process . env . ANALYTICS_SCRIPT_NAME } ` ) ;
18
+
19
+ try {
20
+ await runQueuePublish ( options ) ;
21
+ logger . info ( `Job completed: ${ process . env . ANALYTICS_SCRIPT_NAME } ` ) ;
22
+ } catch ( e ) {
23
+ logger . error ( `Job exited with error: ${ process . env . ANALYTICS_SCRIPT_NAME } ` ) ;
24
+ logger . error ( e ) ;
25
+ throw e ;
26
+ }
27
+ } ) ( ) ;
Original file line number Diff line number Diff line change @@ -9,7 +9,7 @@ applications:
9
9
health-check-type : process
10
10
buildpacks :
11
11
- nodejs_buildpack
12
- command : node deploy/cron .js
12
+ command : node deploy/publisher .js
13
13
env :
14
14
ANALYTICS_DEBUG : ' true'
15
15
ANALYTICS_LOG_LEVEL : ${ANALYTICS_LOG_LEVEL}
You can’t perform that action at this time.
0 commit comments