0

I'm trying to come up with a very simple implementation for this problem:

  • I have 2 environments behaving under a master-slave paradigm
  • Environment A manages environment B: configures it, runs scripts in it, etc.
  • Environment B cannot initiate communications with environment A
  • Sometimes environment A leaves scripts running in environment B's background [./myScript.sh &], and has no way of knowing when those scripts are finished (well, environment A could just poll B with ps -aux, but I'm looking for a more generic system)

I'd like to create a system that satisfies these conditions:

  • When a background script myScript.sh finishes, it leaves a message in some mailbox
  • Environment A keeps a runner that periodically checks the mailbox in environment B, and consumes all new messages
  • Adding and consuming messages to this 'queue' must be resistant to race conditions / concurrency
  • The solution must be based on Bash

I thought of 2 options:

  • Option A: modeling the mailbox as a file. myScript.sh appends notifications to the file; environment A reads and empties the file via ssh. I guess race conditions could be solved via file locking? I think bash allows this.
  • Option B: much simpler, myScript.sh would leave messages as separate files in a well-known folder which would act as mailbox. Environment A would get the list of files, cat them and remove them.

But perhaps the vast know-how of StackOverflow will propose must better / simpler options.

Thanks!

3

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.