Skip to content

Commit

Permalink
fix logger error & update samples
Browse files Browse the repository at this point in the history
  • Loading branch information
miaowing committed Jun 28, 2019
1 parent 20e0b42 commit a57ca4a
Show file tree
Hide file tree
Showing 8 changed files with 40 additions and 27 deletions.
11 changes: 7 additions & 4 deletions lib/executor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export class Executor {
return false;
}
} catch (e) {
this.logger.error(`Try lock job ${jobKey} fail.`, e);
this.logger.error(`Try lock job ${jobKey} fail. ${e.message}`, e.stack);
return false;
}
}
Expand All @@ -31,7 +31,7 @@ export class Executor {
try {
typeof release === 'function' ? release() : void 0;
} catch (e) {
this.logger.error(`Release lock job ${jobKey} fail.`, e);
this.logger.error(`Release lock job ${jobKey} fail.`, e.stack);
}

return result;
Expand All @@ -46,7 +46,7 @@ export class Executor {
this.clear();
return result;
} catch (e) {
this.logger.error(`Execute job ${jobKey} fail.`, e);
this.logger.error(`Execute job ${jobKey} fail.`, e.stack);
if (
this.configs.maxRetry !== -1 &&
this.currentRetryCount < this.configs.maxRetry
Expand All @@ -63,7 +63,10 @@ export class Executor {
});
return false;
} else {
this.logger.error(`Job ${jobKey} already has max retry count.`, e);
this.logger.error(
`Job ${jobKey} already has max retry count.`,
e.stack,
);
return false;
}
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "nest-schedule",
"version": "0.6.1",
"version": "0.6.2",
"description": "Nest - modern, fast, powerful node.js web framework (@schedule)",
"author": "Miaowing <[email protected]>",
"license": "MIT",
Expand Down
6 changes: 3 additions & 3 deletions samples/distributed-schedule.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,17 @@ export class DistributedScheduleService extends NestDistributedSchedule {
super();
}

@Interval(2000)
@Interval(2000, { key: 'distributed-schedule-interval' })
interval(): void {
console.log('executing interval job');
}

@Timeout(2000)
@Timeout(2000, { key: 'distributed-schedule-timeout' })
timeout() {
console.log('executing timeout job');
}

@Cron('*/2 * * * * *')
@Cron('*/2 * * * * *', { key: 'distributed-schedule-cron' })
cron() {
console.log('executing cron job');
}
Expand Down
2 changes: 1 addition & 1 deletion samples/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { NestCloud } from '@nestcloud/core';
async function bootstrap() {
const app = NestCloud.create(await NestFactory.create(AppModule));
// const app = await NestFactory.create(AppModule);
await app.listen(3000);
await app.listen(3001);
}

bootstrap();
6 changes: 3 additions & 3 deletions samples/nestcloud.schedule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,17 @@ import { MyLocker } from './my.locker';

@Injectable()
export class NestcloudSchedule extends NestSchedule {
@Interval(2000)
@Interval(2000, { key: 'nestcloud-schedule-interval' })
interval(): void {
console.log('executing interval job');
}

@Timeout(2000)
@Timeout(2000, { key: 'nestcloud-schedule-timeout' })
timeout() {
console.log('executing timeout job');
}

@Cron('*/2 * * * * *')
@Cron('*/2 * * * * *', { key: 'nestcloud-schedule-cron' })
@UseLocker(MyLocker)
cron() {
console.log('executing cron job');
Expand Down
6 changes: 3 additions & 3 deletions samples/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@
"start": "ts-node -r tsconfig-paths/register ./main.ts"
},
"dependencies": {
"@nestcloud/common": "^0.3.0-beta4",
"@nestcloud/core": "^0.2.1",
"@nestcloud/common": "^0.3.17",
"@nestcloud/core": "^0.3.17",
"@nestjs/common": "^6.0.4",
"@nestjs/core": "^6.0.4",
"@nestjs/microservices": "^6.0.4",
"@nestjs/platform-express": "^6.0.4",
"@nestjs/websockets": "^6.0.4",
"nest-schedule": "^0.5.0",
"nest-schedule": "^0.6.2",
"reflect-metadata": "0.1.13",
"rimraf": "2.6.3",
"rxjs": "6.4.0"
Expand Down
6 changes: 3 additions & 3 deletions samples/schedule.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@ import { Interval, Timeout, Cron, NestSchedule } from 'nest-schedule';

@Injectable()
export class ScheduleService extends NestSchedule {
@Interval(2000)
@Interval(2000, { key: 'schedule-interval' })
interval(): void {
console.log('executing interval job');
}

@Timeout(2000)
@Timeout(2000, { key: 'schedule-timeout' })
timeout() {
console.log('executing timeout job');
}

@Cron('*/2 * * * * *')
@Cron('*/2 * * * * *', { key: 'schedule-cron' })
cron() {
console.log('executing cron job');
}
Expand Down
28 changes: 19 additions & 9 deletions samples/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,22 @@
# yarn lockfile v1


"@nestcloud/common@^0.3.0-beta4":
version "0.3.0-beta4"
resolved "https://registry.yarnpkg.com/@nestcloud/common/-/common-0.3.0-beta4.tgz#3b1d22aa52b26c468b3e661bd600d041da9dac8b"
"@nestcloud/common@^0.3.17":
version "0.3.17"
resolved "https://registry.yarnpkg.com/@nestcloud/common/-/common-0.3.17.tgz#73f78429aaed59b38979ec7e540299ce52dce818"
integrity sha512-rklzLHu/W5jQCxlYHqkoimWZpVLL2JKtC3YNS2DcTvvTr/1TA/9ToZsJuqkj+uvyCgI6cM0iqGcaVIhaF5qkBw==
dependencies:
lodash "^4.17.11"

"@nestcloud/core@^0.2.1":
version "0.2.3"
resolved "https://registry.yarnpkg.com/@nestcloud/core/-/core-0.2.3.tgz#ca1b5126421691d33aac672a7215e5baa3d4b704"
"@nestcloud/core@^0.2.3":
version "0.2.4"
resolved "https://registry.yarnpkg.com/@nestcloud/core/-/core-0.2.4.tgz#4848af409e0ea61df6ba263059e1cfe5900fab52"
integrity sha512-kDiAblUH4ZQnDzhZLp5oplUIjm+S/N+mVpCfZGj9QN9KDdTERW1gl/CW/aLVmdOIIvf/9cmigoqTMK/4k0uGNg==

"@nestcloud/core@^0.3.17":
version "0.3.17"
resolved "https://registry.yarnpkg.com/@nestcloud/core/-/core-0.3.17.tgz#2372aebb1b2cff55c4e68a9feb168f42ec1bdc69"
integrity sha512-rZkbvrcV5Vst31aOzWJuHBGA0HMtsmD5QMJGbK5LO7NMnM/tdpKwt01h57qQnfhOWWG0wobrfy+KZyNYsI/hgg==

"@nestjs/common@^6.0.4":
version "6.1.1"
Expand Down Expand Up @@ -630,12 +637,15 @@ [email protected]:
version "0.6.1"
resolved "https://registry.yarnpkg.com/negotiator/-/negotiator-0.6.1.tgz#2b327184e8992101177b28563fb5e7102acd0ca9"

nest-schedule@^0.4.6:
version "0.4.6"
resolved "https://registry.yarnpkg.com/nest-schedule/-/nest-schedule-0.4.6.tgz#81cf5f6e9bb9efc9a49f2e1376027a2eee14f92c"
nest-schedule@^0.6.2:
version "0.6.2"
resolved "https://registry.yarnpkg.com/nest-schedule/-/nest-schedule-0.6.2.tgz#c992a6db10affc2bab91e1e805ca38dd8b9ad385"
integrity sha512-9R8+M6ZB2/pkhxq3GOwpj/MAGGDQGPJ1ZUq5kT8AeFicKKDf/8+I9T6DgDtwzYUlzvCzz+j+TzHZ/UlFdP/UiQ==
dependencies:
node-schedule "^1.3.0"
reflect-metadata "^0.1.12"
optionalDependencies:
"@nestcloud/core" "^0.2.3"

next-tick@1, next-tick@^1.0.0:
version "1.0.0"
Expand Down

0 comments on commit a57ca4a

Please sign in to comment.