File tree Expand file tree Collapse file tree 12 files changed +430
-149
lines changed Expand file tree Collapse file tree 12 files changed +430
-149
lines changed 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
+ 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 = "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