Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

could you add a new command to run producer? #1

Open
scil opened this issue Jul 1, 2022 · 3 comments
Open

could you add a new command to run producer? #1

scil opened this issue Jul 1, 2022 · 3 comments

Comments

@scil
Copy link

scil commented Jul 1, 2022

Thank you for your article.

maybe you can add a new command

    "producer": "tsc-watch --onSuccess \"node ./dist/producer.js\" | pino-pretty",
@manast
Copy link
Contributor

manast commented Jul 1, 2022

Thank you for the suggestion!

@notflip
Copy link

notflip commented Dec 6, 2022

@scil What is a good way of doing this? I'm looking for a bullmq example repo that shows how to structure commands to run index and the producer at the same moment. I have not found a good example.

@scil
Copy link
Author

scil commented Dec 8, 2022

there is the index.ts from one of my repo which is used to auto commit any git repo.

import { Worker, QueueScheduler } from "bullmq";
import { commitRepoQueueName ,connection } from "./types";


const commitRepoWorker = new Worker(commitRepoQueueName, `${__dirname}/workers/auto-commit-worker.js`, {
  connection,
});

const commitRepoScheduler = new QueueScheduler(commitRepoQueueName, {
  connection,
});

process.on("SIGTERM", async () => {
  console.info("SIGTERM signal received: closing queues");

  await commitRepoWorker.close();
  await commitRepoScheduler.close();

  console.info("All closed");
});

and the package.json

{
  "name": "bullmq-typescript",
  "version": "1.0.0",
  "description": "to BullMQ to auto commit git repo",
  "license": "MIT",
  "bin": "src/index.ts",
  "scripts": {
    "build": "tsc",
    "worker": "node ./dist/index.js",
    "producer": "node ./dist/producer.js",
    "dev:worker": "tsc-watch --onSuccess \"node ./dist/index.js\" | pino-pretty",
    "dev:producer": "tsc-watch  --onSuccess \"node ./dist/producer.js\" | pino-pretty",
    "test": "ts-mocha ./tests/**/*.test.ts"
  },
  "repository": {
    "type": "git",
    "url": "https://github.com/taskforcesh/bullmq-typescript.git"
  },
  "keywords": [
    "bullmq"
  ],
  "author": "Manuel Astudillo",
  "dependencies": {
    "bullmq": "^1.85.3",
    "consola": "^2.15.3",
    "cronstrue": "^2.11.0",
    "shelljs": "^0.8.5"
  },
  "devDependencies": {
    "@types/node": "^17.0.41",
    "chai": "^4.2.0",
    "mocha": "^6.0.1",
    "node-cmd": "^5.0.0",
    "pino-pretty": "^8.1.0",
    "ts-mocha": "^10.0.0",
    "tsc-watch": "^5.0.3",
    "typescript": "^4.7.3"
  }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants