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

execution from cron throws SyntaxError: Unexpected end of JSON input #26

Open
fullaware opened this issue Nov 19, 2018 · 1 comment
Open

Comments

@fullaware
Copy link

fullaware commented Nov 19, 2018

I'm executing mgeneratejs via cron and receive SyntaxError: Unexpected end of JSON input. This does not happen if I execute the script directly:

mgenerate.sh script contents

mgeneratejs '{"name": "$name", "age": "$age", "emails": {"$array": {"of": "$email", "number": 3}}}' -n 50 | mongoimport --port 27018 -d customers -c contacts

When executed manually I get the following results and the data is successfully imported:

$ /data/UPLOAD/mgenerate.sh
2018-11-19T10:47:27.878-0500	connected to: localhost:27018
2018-11-19T10:47:28.672-0500	imported 50 documents

However when executed via cron I see the following error in mail and no documents are imported:

2018-11-19T10:45:01.577-0500	connected to: localhost:27018
undefined:1

SyntaxError: Unexpected end of JSON input
    at Object.parse (native)
    at Socket.<anonymous> (/usr/lib/node_modules/mgeneratejs/bin/mgenerate.js:94:21)
    at emitNone (events.js:91:20)
    at Socket.emit (events.js:185:7)
    at endReadableNT (_stream_readable.js:978:12)
    at _combinedTickCallback (internal/process/next_tick.js:80:11)
    at process._tickCallback (internal/process/next_tick.js:104:9)
2018-11-19T10:45:02.304-0500	imported 0 documents

I've installed globally npm install -g mgeneratejs for both my user as well as root.

While I do miss having this GREAT tool in Python:mtools, its still the best tool out there! Great work guys!

@rueckstiess
Copy link
Owner

Hi, sorry for the delayed response. I'm not quite sure how I can help with this. We'd need to better understand what the cron job is doing differently. Did you ever figure out what the problem was?

"While I do miss having this GREAT tool in Python:mtools, its still the best tool out there! Great work guys!"

I just felt it didn't really fit into the mtools collection as mgeneratejs doesn't deal with log files or launching mongodb instances. The Javascript version is also faster and has more features due to chance.js and faker.js.

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

2 participants