CLI Load Registrations and Registration Best Practice
See original GitHub issuenode.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:
- Created a year ago
- Comments:8 (3 by maintainers)

Top Related StackOverflow Question
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.
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:
where
one.jsandtwo.jslook like:and require them like this:
I’m open to suggestions here and would like to keep it simple. Any thoughts?