moleculerjs / moleculer-cli Goto Github PK
View Code? Open in Web Editor NEW:herb: Command line tool for Moleculer
Home Page: http://moleculer.services/docs/moleculer-cli.html
License: MIT License
:herb: Command line tool for Moleculer
Home Page: http://moleculer.services/docs/moleculer-cli.html
License: MIT License
I'm using this command to run a script from a CRON:
#!/bin/sh
moleculer call \
--ns="localdev" \
-t "nats://nats:4222" \
"myservice.test"
RESULT=$?
echo "Done"
exit $RESULT
The test
action is as simple as:
module.exports = {
name: 'myservice',
actions: {
test(ctx) {
return 0;
}
}
};
When running the script locally, logs show the returned value (here 0
), but script doesn't stop. It's still runnnig.
Checking the call/index.js
code of this repo, I see that when an error is thrown, process.exit()
is called and script ends. But when everything goes right, the broker is stopped, but no process.exit()
is called.
https://github.com/moleculerjs/moleculer-cli/blob/master/src/call/index.js#LL75C24-L75C24
Because of that, CRON job can't detect the end of the script. After a few days, I have tons of CRON jobs running in the wild.
Should the successful call be followed by an exit code of zero, or should I explore an other way to say to my CRON "ok, job's done"?
Thanks.
The current install process for templates uses npm only to install dependencies after initializing a project by template as seen below:
moleculer-cli/src/init/index.js
Lines 260 to 268 in bf2dabf
What I propose is that this be modified to look for a yarn.lock file provided in the template, if a yarn.lock is not found then default to npm install. This change should be relatively simple and will allow those users that use yarn to have dependencies installed with yarn when prompted if dependencies should be installed. Currently users that use yarn init a template then must select no to installing dependencies in order to then install them via yarn, this change would bring the experience of using yarn inline with users using npm.
Hi there
I'm making a service generator for our services that are using moleculer and as part of that I'm using the moleculer-cli init function to upgrade services that already exist. Basically the process that I've automated thus far is delete all files that aren't logic relating to the function of the service itself and then run moleculer init again (there's a bit more to it but I'll save you the explanation as that isn't the issue).
This upgrade process is something that I plan to run quite frequently and I want to be able to just quickly hit enter through the prompts. But when I get to the overwrite one it's defaulted to false so I end up accidentally exiting out of the process.
I was wondering if it would be alright for us to modify the code for init so that we could put a flag in the meta.js to toggle whether we want to have that prompt or not. Basically we could just add a line before this one that would be something like:
if (templateMetadata.promptForProjectOverwrite === false) return;
I'm happy to put in a PR for this but wanted to raise the issue first to make sure that this was ok with the project maintainers.
Cheers
Zac
After creating a new project and with AMQP as transporter selected, the docker-compose up
command fails with the following error.
ERROR: Service 'greeter' depends on service 'amqp' which is undefined.
Renaming amqp
with rabbit
in the docker-compose
file let it work.
Similar to https://moleculer.services/docs/0.14/runner.html#env-files, can we have support for --envfile
and env
My environment:
OS: Darwin failbowl.turner.com 16.5.0 Darwin Kernel Version 16.5.0: Fri Mar 3 16:52:33 PST 2017; root:xnu-3789.51.2~3/RELEASE_X86_64 x86_64
Node: v7.9.0
NPM: 4.2.0
Issue:
After running npm install -g moleculer-cli
, the moleculer
command will not execute properly. This appears to be related to some newline encoding within bin/moleculer.js
.
❯ moleculer
env: node\r: No such file or directory
Need to add an override of the configuration from env
as it is done in the runner. Now can setting cacher
only in config.moleculer.js
Duplicate entries for ioredis in generated package.json when running the command moleculer init project-simple first-demo
and selecting redis for transporter and for cache.
Hey guys, first of all - thanks for your work! I will consider creating PR for this issue, but.
When I use cli, and select AMQP and Redis for caching I run 'npm run dev' which fails, because Redis and Rabbitmq is not running or configured, so my proposition will be - add steps to run/configure it.
Feedback appreceated. Thanks in advance.
Need to test:
create
commandinit
commandconnect
commandstart
commandalias-template
commandSimilar tests: https://github.com/vuejs/vue-cli/blob/v2/test/e2e/test.js
Hello there,
I've been trying to use the moleculer-cli with a custom template to act as a service generator and upgrader. One of the last pieces to the puzzle is the new promptForProjectOverwrite property.
I noticed this morning when updating my moleculer-cli version that the new version hasn't been published to npm yet so the change can't be pulled down using npm install.
Can this be updated please?
Thanks!
Amber
What is the current behavior?
Installing the cli tool throws the error:
npm WARN deprecated [email protected]: CoffeeScript on NPM has moved to "coffeescript" (no hyphen)
What is the expected behavior?
The installation should work as long as the dependencies point to the correct location
Which versions of molecular-cli, and which browser / OS are affected by this issue? Did this work in previous versions?
Building the library inside a Docker node:8 container with a non-root user -u 1000 on OS X
Error: Missing helper: "if_eq"
{ Error: Missing helper: "if_eq"
at Object.<anonymous> (/Users/fugufish/node_modules/handlebars/dist/cjs/handlebars/helpers/helper-missing.js:19:13)
at Object.eval [as main] (eval at createFunctionContext (/Users/fugufish/node_modules/handlebars/dist/cjs/handlebars/compiler/javascript-compiler.js:254:23), <anonymous>:29:78)
at main (/Users/fugufish/node_modules/handlebars/dist/cjs/handlebars/runtime.js:175:32)
at ret (/Users/fugufish/node_modules/handlebars/dist/cjs/handlebars/runtime.js:178:12)
at ret (/Users/fugufish/node_modules/handlebars/dist/cjs/handlebars/compiler/compiler.js:526:21)
at /Users/fugufish/node_modules/consolidate/lib/consolidate.js:876:16
at /Users/fugufish/node_modules/consolidate/lib/consolidate.js:161:5
at Promise._execute (/Users/fugufish/node_modules/bluebird/js/release/debuggability.js:313:9)
at Promise._resolveFromExecutor (/Users/fugufish/node_modules/bluebird/js/release/promise.js:483:18)
at new Promise (/Users/fugufish/node_modules/bluebird/js/release/promise.js:79:10)
at promisify (/Users/fugufish/node_modules/consolidate/lib/consolidate.js:154:10)
at exports.handlebars.render (/Users/fugufish/node_modules/consolidate/lib/consolidate.js:866:10)
at /Users/fugufish/node_modules/moleculer-cli/src/init/index.js:319:6
at /Users/fugufish/node_modules/moleculer-cli/node_modules/async/dist/async.js:3880:24
at replenish (/Users/fugufish/node_modules/moleculer-cli/node_modules/async/dist/async.js:1011:17)
at /Users/fugufish/node_modules/moleculer-cli/node_modules/async/dist/async.js:1016:9
at eachOfLimit (/Users/fugufish/node_modules/moleculer-cli/node_modules/async/dist/async.js:1041:24)
at /Users/fugufish/node_modules/moleculer-cli/node_modules/async/dist/async.js:1046:16
at _parallel (/Users/fugufish/node_modules/moleculer-cli/node_modules/async/dist/async.js:3879:5)
at Object.series (/Users/fugufish/node_modules/moleculer-cli/node_modules/async/dist/async.js:4735:5)
at async.each (/Users/fugufish/node_modules/moleculer-cli/src/init/index.js:310:10)
at /Users/fugufish/node_modules/moleculer-cli/node_modules/async/dist/async.js:3110:16
description: undefined,
fileName: undefined,
lineNumber: undefined,
message: 'Missing helper: "if_eq"',
name: 'Error',
number: undefined }
I want to use the moleculer-repl's new feature,but it's version is old
--namespace dev
I noticed the init is missing the raw-helper helper from handlebars : https://handlebarsjs.com/guide/block-helpers.html#raw-blocks
When creating complex moleculer templates with frontends that have {{ }} variables in them the raw-helper should then output the intended code block. e.g.
{{{{raw-helper}}}}
{{bar}}
{{{{/raw-helper}}}}
will output
{{bar}}
This is especially helpful with vue templates to preserve the template frontend code.
Warning on install:
moleculer-cli > [email protected]: request has been deprecated, see https://github.com/request/request/issues/3142
Add more file generator to create
command:
Cannot install moleculer-cli in Windows 10 bash shell
$ npm i -g moleculer-cli
npm WARN deprecated [email protected]: Please upgrade to Chalk 2.1.0 - template literals in this version (2.0.1) are quite buggy.
npm ERR! path /home/xmrg/.nvm/versions/node/v8.1.4/lib/node_modules/moleculer-cli/node_modules/es5-ext
npm ERR! code ENOENT
npm ERR! errno -2
npm ERR! syscall rename
npm ERR! enoent ENOENT: no such file or directory, rename '/home/xmrg/.nvm/versions/node/v8.1.4/lib/node_modules/moleculer-cli/node_modules/es5-ext' -> '/home/xmrg/.nvm/versions/node/v8.1.4/lib/node_modules/moleculer-cli/node_modules/.es5-ext.DELETE'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent
npm ERR! A complete log of this run can be found in:
npm ERR! /home/xmrg/.npm/_logs/2017-08-24T08_15_58_523Z-debug.log
I'd like to be able to run the init function in a non-interactive way.
Supplying a file with the answers for the init function.
jHipster is using yeoman for their init scripts and it saves all their answers in a .yo.rc.json file that contains all the answers to the questions that were posed.
As a bonus they can use that file to for future upgrade scripts.
Moleculer command not found after running npm i moleculer-cli -g
OS: Catalina v0.15.4
Node: v10.16.0
NPM: v6.9.0
See:
moleculer-cli/src/connect/index.js
Line 88 in 0d6f9a5
This could probably be "fixed" in moleculer core, however.
I get the following error on trying to initialise a moleculer project -
Failed to download repo from 'moleculerjs/moleculer-template-project'!
Using moleculer connect --config ./moleculer.config.js
transport is not loaded properly.
To verify this after running the command and executing info
most of the config is loaded, while the transporter stays TCP
Hi, try to run moleculer cli.
I try to install npm install moleculer-repl
but nothing changes. Reinstall npm i moleculer-cli -g the same.. Any ideas? Thanks!
Hi, can you document somewhere all cli flags?
eg. I found --no-install
for init
accidentally and it seems to be useful in some cases.
I have a configuration file that specifies an in memory cacher (tried both cacher true and with options), yet the service broker never has any cacher active.
info
shows that the config loaded is correct, i.e. cacher is true, but it also shows in the broker section that cacher is none, what am I missing here? Obviously the cache commands then complain about there being no cacher.
Node version : v12.22.8
Moleculer version : 0.14.19
Protocol version : 4
---
Namespace : <None>
Node ID : cli-desktop-po9k7n1-32464
Services : 1
Actions : 7
Events : 0
Strategy : RoundRobinStrategy
Cacher : <None>
Nodes : 2
---
default
namespace : ""
metadata
logger
type : "Console"
logLevel : "info"
cacher : true
serializer : "JSON"
requestTimeout : 10000
.....
Following the documentation, when I create a custom Transport, and try to use it by creating a project with moleculer-cli, it doesn't work
https://moleculer.services/docs/0.12/transporters.html#Custom-transporter
https://github.com/moleculerjs/moleculer/blob/master/src/transporters/index.js#L40
My transporter
https://github.com/devalexandre/Moleculer-Transport-AmazonSQS
transporter:new SQSTransporter({
accessKeyId: "",
secretAccessKey: "/YyJK8mZm01edfKAmwuPhq3NLUEnl",
region: "us-east-1",
apiVersion: "2006-03-01",
}),
[2021-11-30T03:30:13.674Z] INFO melissa-129929/BROKER: Moleculer v0.14.18 is starting...
[2021-11-30T03:30:13.674Z] INFO melissa-129929/BROKER: Namespace: <not defined>
[2021-11-30T03:30:13.674Z] INFO melissa-129929/BROKER: Node ID: melissa-129929
[2021-11-30T03:30:13.675Z] INFO melissa-129929/REGISTRY: Strategy: RoundRobinStrategy
[2021-11-30T03:30:13.676Z] INFO melissa-129929/REGISTRY: Discoverer: LocalDiscoverer
[2021-11-30T03:30:13.677Z] INFO melissa-129929/BROKER: Serializer: JSONSerializer
[2021-11-30T03:30:13.681Z] INFO melissa-129929/BROKER: Validator: FastestValidator
[2021-11-30T03:30:13.683Z] INFO melissa-129929/BROKER: Registered 14 middleware(s).
[2021-11-30T03:30:13.684Z] INFO melissa-129929/TRANSPORTER: NATS lib version: 2.4.0
[2021-11-30T03:30:13.684Z] INFO melissa-129929/BROKER: Transporter: NatsTransporter
[2021-11-30T03:30:13.753Z] INFO melissa-129929/API: API Gateway server created.
[2021-11-30T03:30:13.754Z] INFO melissa-129929/API: Register route to '/api'
[2021-11-30T03:30:13.768Z] INFO melissa-129929/API: ♻ Generate aliases for '/api' route...
[2021-11-30T03:30:13.768Z] INFO melissa-129929/API:
[2021-11-30T03:30:13.769Z] INFO melissa-129929/TRANSIT: Connecting to the transporter...
[2021-11-30T03:30:13.804Z] ERROR melissa-129929/TRANSPORTER: NATS error. CONNECTION_REFUSED
[2021-11-30T03:30:13.804Z] WARN melissa-129929/TRANSIT: Connection is failed. CONNECTION_REFUSED
^C[2021-11-30T03:30:16.917Z] INFO melissa-129929/$NODE: Service '$node' stopped.
[2021-11-30T03:30:16.917Z] INFO melissa-129929/API: Service 'api' stopped.
[2021-11-30T03:30:16.917Z] INFO melissa-129929/GREETER: Service 'greeter' stopped.
[2021-11-30T03:30:16.918Z] INFO melissa-129929/BROKER: ServiceBroker is stopped. Good bye.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.