Bugfixes in sending campaigns

This commit is contained in:
Tomas Bures 2018-09-27 21:32:35 +02:00
parent 2d667523a1
commit 1448d9e914
34 changed files with 95 additions and 55 deletions

View file

@ -1,7 +1,7 @@
'use strict';
const fork = require('child_process').fork;
const log = require('npmlog');
const log = require('./log');
const path = require('path');
const knex = require('../lib/knex');
const {CampaignStatus} = require('../shared/campaigns');
@ -12,10 +12,8 @@ let senderProcess;
function spawn(callback) {
log.verbose('Senders', 'Spawning master sender process');
knex.transaction(async tx => {
await tx('campaigns').where('status', CampaignStatus.SENDING).update({status: CampaignStatus.SCHEDULED});
}).then(() => {
knex('campaigns').where('status', CampaignStatus.SENDING).update({status: CampaignStatus.SCHEDULED})
.then(() => {
senderProcess = fork(path.join(__dirname, '..', 'services', 'sender-master.js'), [], {
cwd: path.join(__dirname, '..'),
env: {NODE_ENV: process.env.NODE_ENV}