fix worker not finding unprocessed segments
parent
f9b98cc120
commit
ca94b1c1a0
|
@ -1,2 +1,2 @@
|
||||||
DB_HOST=db
|
DB_HOST=db
|
||||||
STORAGE_PATH=/realdata
|
STORAGE_PATH=/realdata/
|
||||||
|
|
|
@ -69,7 +69,11 @@ router.get('/v1.1/devices/:dongleId/', runAsyncWrapper(async (req, res) => {
|
||||||
const device = await deviceController.getDeviceFromDongleId(dongleId);
|
const device = await deviceController.getDeviceFromDongleId(dongleId);
|
||||||
if (!device) {
|
if (!device) {
|
||||||
logger.info(`HTTP.DEVICES device ${dongleId} not found`);
|
logger.info(`HTTP.DEVICES device ${dongleId} not found`);
|
||||||
return res.status(404).json({ is_paired: false, prime: false });
|
return res.status(200).json({
|
||||||
|
is_paired: false,
|
||||||
|
prime: false,
|
||||||
|
prime_type: 0,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
const {
|
const {
|
||||||
|
|
|
@ -4,7 +4,12 @@ import log4js from 'log4js';
|
||||||
|
|
||||||
import app from './app';
|
import app from './app';
|
||||||
import storageController from './controllers/storage';
|
import storageController from './controllers/storage';
|
||||||
import orm, { Accounts, Devices, Drives } from '../models';
|
import orm, {
|
||||||
|
Accounts,
|
||||||
|
Devices,
|
||||||
|
Drives,
|
||||||
|
DriveSegments,
|
||||||
|
} from '../models';
|
||||||
|
|
||||||
export default async () => {
|
export default async () => {
|
||||||
const logger = log4js.getLogger();
|
const logger = log4js.getLogger();
|
||||||
|
@ -25,12 +30,22 @@ export default async () => {
|
||||||
logger.info('Database synced', options);
|
logger.info('Database synced', options);
|
||||||
|
|
||||||
// debug: print out some info from the database
|
// debug: print out some info from the database
|
||||||
Promise.all([Accounts.findAll(), Devices.findAll(), Drives.findAll()])
|
await Promise.all([
|
||||||
.then(([accounts, devices, drives]) => {
|
Accounts.findAll(),
|
||||||
logger.info(`Found ${accounts.length} accounts`);
|
Devices.findAll(),
|
||||||
logger.info(`Found ${devices.length} devices`);
|
Drives.findAll(),
|
||||||
logger.info(`Found ${drives.length} drives`);
|
DriveSegments.findAll(),
|
||||||
});
|
]).then(([
|
||||||
|
accounts,
|
||||||
|
devices,
|
||||||
|
drives,
|
||||||
|
driveSegments,
|
||||||
|
]) => {
|
||||||
|
logger.info(`Found ${accounts.length} accounts`);
|
||||||
|
logger.info(`Found ${devices.length} devices`);
|
||||||
|
logger.info(`Found ${drives.length} drives`);
|
||||||
|
logger.info(`Found ${driveSegments.length} drive segments`);
|
||||||
|
});
|
||||||
|
|
||||||
const httpServer = http.createServer(await app());
|
const httpServer = http.createServer(await app());
|
||||||
httpServer.listen(process.env.HTTP_PORT, () => {
|
httpServer.listen(process.env.HTTP_PORT, () => {
|
||||||
|
|
|
@ -252,9 +252,10 @@ async function updateSegments() {
|
||||||
where: {
|
where: {
|
||||||
upload_complete: false,
|
upload_complete: false,
|
||||||
is_stalled: false,
|
is_stalled: false,
|
||||||
process_attempts: {
|
[Op.or]: [
|
||||||
[Op.lt]: 5,
|
{ process_attempts: { [Op.lt]: 5 } },
|
||||||
},
|
{ process_attempts: null },
|
||||||
|
],
|
||||||
},
|
},
|
||||||
order: [['created', 'ASC']],
|
order: [['created', 'ASC']],
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue