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 Amanages- environment B: configures it, runs scripts in it, etc.
- Environment Bcannot initiate communications with- environment A
- Sometimes environment Aleaves scripts running inenvironment B's background [./myScript.sh &], and has no way of knowing when those scripts are finished (well,environment Acould just pollBwithps -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.shfinishes, it leaves a message in some mailbox
- Environment Akeeps 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.shappends notifications to the file;environment Areads 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.shwould leave messages as separate files in a well-known folder which would act as mailbox.Environment Awould get the list of files,catthem and remove them.
But perhaps the vast know-how of StackOverflow will propose must better / simpler options.
Thanks!
