How to run this redis-cli bash command in node.js?

53 views
Skip to first unread message

Peppy

unread,
Apr 8, 2018, 1:31:57 AM4/8/18
to Redis DB
Greetings,

I am trying to run this command in node.js:

redis-cli --scan --pattern 'sockets:*' | xargs redis-cli del

This command needs to run when my node.js server crashes and then restarts. I am also using pm2 and clustering with just 1 instance, so the server restarts automatically. I need to have these prefixed keys completely removed before they can be repopulated.

The command above works on the command line. How do I get it to run in node upon restart?

Thanks
Kind regards

Tuco

unread,
Apr 9, 2018, 1:23:19 AM4/9/18
to Redis DB
Shouldn't this be part of some node.js forum?
Maybe you should just try to search how to execute a shell script from node.js

Peppy

unread,
Apr 9, 2018, 11:12:19 AM4/9/18
to Redis DB
Thanks a lot, the "child-process" in node.js was exactly what I was looking for.
Reply all
Reply to author
Forward
0 new messages