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

Inter-Process Communication #498

Merged
merged 9 commits into from
Aug 18, 2024
Merged

Inter-Process Communication #498

merged 9 commits into from
Aug 18, 2024

Conversation

gustavohenke
Copy link
Member

@gustavohenke gustavohenke commented Aug 13, 2024

This PR implements basic inter-process communication (IPC), which is an API-only feature - not available through CLI.

Command has the following new fields/methods:

  • send: to send messages
  • messages.incoming: to listen for received messages
  • messages.outgoing: to listen for sent messages

The caller must set the ipc property when calling concurrently(). It sets the number of the file descriptor on which to set up the IPC channel.

Example usage:

const { commands } = concurrently([{ command: 'echo foo', ipc: 3 }]);
commands[0].send({ hello: 'world' })
commands[0].messages.incoming.subscribe(({ message }) => {
	console.log('command 0 sent this:', message);
});

With this PR I also realise that the README is no longer a good option for documentation.
We need to expand it into a website...

@gustavohenke gustavohenke linked an issue Aug 13, 2024 that may be closed by this pull request
@gustavohenke gustavohenke marked this pull request as ready for review August 13, 2024 06:55
@gustavohenke gustavohenke changed the title IPC Inter-Process Communication Aug 13, 2024
@coveralls
Copy link

Coverage Status

coverage: 99.178% (+0.03%) from 99.144%
when pulling 14b318a on ipc
into 23f97ac on main.

@gustavohenke gustavohenke added this to the v9 milestone Aug 15, 2024
@gustavohenke gustavohenke merged commit b91d0c3 into main Aug 18, 2024
21 checks passed
@gustavohenke gustavohenke deleted the ipc branch August 18, 2024 10:56
@gustavohenke
Copy link
Member Author

🚢 This is now available in v9.0.0!
https://github.com/open-cli-tools/concurrently/releases/tag/v9.0.0

@studiosciences
Copy link

This is great! Thx @gustavohenke.

I created a simple "waitForStartMessage.js" script, so that I could delay a process until our Orval code generation process is setup.

    {
      command: `node ${__dirname}/waitForStartMessage.js && yarn start`,
      name: "ui",
      ipc: 3,
    },

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow commands IPC
3 participants