I want to use shell commands like git clone in a nestjs queue Consumer. But when i execute the command with shelljs it just skips these and ends the job. Any idea why i'm getting my test logs but not the ls executed? I tried it in sync and async but both show the same behaviour.
this is my consumer
import { Process, Processor } from '@nestjs/bull';
import { Job } from 'bull';
import shell from 'shelljs';
@Processor('scan_scm')
export class SCMConsumer {
@Process()
async transcode(job: Job<unknown>) {
console.log('scm-info2');
console.log(job.data);
console.log('test');
// Run external tool synchronously
const result = await shell.exec('ls -la', { async: true });
console.log(result.exitCode);
if (result.exitCode !== 0) {
console.log(result.stdout);
}
console.log(result);
return result;
}
}
this is my app module
@Module({
imports: [
BullModule.forRoot({
redis: {
host: 'localhost',
port: 6379,
},
}),
BullModule.registerQueue({
name: 'scan_scm',
}),
SCMConsumer,
],
controllers: [AppController],
providers: [AppService],
})
export class AppModule {}
this is my service
@Injectable()
export class AppService {
constructor(@InjectQueue('scan_scm') private jobQueue: Queue) {}
getHello(): string {
return 'Hello World!';
}
addToQueue(object: any) {
this.jobQueue.add(object);
}
}
and this is my controller
import { Controller, Get, Param } from '@nestjs/common';
import { AppService } from './app.service';
@Controller()
export class AppController {
constructor(private readonly appService: AppService) {}
@Get(':id')
getHello(@Param('id') id): any {
this.appService.addToQueue({ test: id });
return { test: id };
}
}