Skip to content

After "call" command is successfully done, script is still running and never stops #71

@tafel

Description

@tafel

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions