question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

CLI Load Registrations and Registration Best Practice

See original GitHub issue

node.js version: 14.17.1 npm/yarn version: 7.6.1 faktory-server version: 1.6.1 facktory-worker package version:4.4.0

Hi,

I see the CLI option for starting using node_modules/.bin/faktory-work, however, whenever I start the process that way any jobs get an error saying undefined: No jobtype registered: <jobname>.

This makes sense as the command line tool doesn’t seem to allow for any jobs to be registered. Am I missing something about how jobs can be registered to the cli spawned worker?

Related, is the a best practice for how users load a potentially large number of registrations attached to a worker? For example do people create a jobs or tasks folder where each file contains a worker.register() call and require the whole folder, or have all the register calls in one worker.js file that then call out to other modules?

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
imackcommented, Sep 6, 2022

I checked the Ruby and Go official libraries, seems like they take different approaches best aligned with the respective platforms.

I think what we have so far is fine and maybe a strong defaults isn’t necessarily the right “node” answer. I think the command line import unblocks what I need it for, so I’m content to close this for now unless a better Node dev than me has more thoughts. Listing imports is fine for me.

1reaction
jbielickcommented, Aug 31, 2022

Hi there,

Thanks for opening the issue and discussion. Allowing job code to be required by the CLI was a longstanding item on the roadmap. Since you mentioned it, I’ve added a barebones implementation and released it in 4.5.0.

I think there are a couple ways of structuring the job code and making it require-able, but if you want my opinion I would do something like this:

jobs/
├── one.js
└── two.js

where one.js and two.js look like:

const faktory = require("faktory-worker");

const one = (...args) => {
  console.log(args);
};

faktory.register("one", one);

module.exports = one;

and require them like this:

faktory-work -r ./jobs/*

I’m open to suggestions here and would like to keep it simple. Any thoughts?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Installing and Configuring the AWS CLI
You must run register with appropriate permissions. You can get permissions by using an IAM role, or less optimally, by installing user credentials...
Read more >
Four Best Practices for Cellular Module Registration - Twilio
Best Practices for Cellular Module Registration and how to Future-proof your IoT application against 2G and 3G Switch-offs.
Read more >
Angular 10 - User Registration and Login Example & Tutorial
Tutorial with example of how to implement user registration, login and CRUD functionality with Angular 10. Includes boilerplate app and ...
Read more >
Write custom WP-CLI commands
The best practices outlined here are an extension of the developer documentation in the WP-CLI Handbook and the Commands Cookbook. A custom WP- ......
Read more >
Cisco EEM Best Practices
If the policy type option is not provided when registering a policy, ... the EEM CLI session and the other must remain free...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found