Suppose, I have 10 PCs, all are using the same framework based on node.js, and each of them will have some output field's data. There is one common output file to be created through code, to which every PC could be able to write their respective contents properly.
Main bottleneck or the problem I am thinking is, if two or more PCs will try to access the same file at the same time or when the file is already in use by other, then the code will fail and will throw an error.
So, my main queries are: How would the code know before updating the content into file, that the file is not in use, or is accessible? How to have concurrent updation to file from different PCs at once (one row for each PC)?
I googled a lot regarding the same, but no where I got any solution or hint. So, reaching out here to get some advice from the node.js/JavaScript experts on the forum. Please provide some hint/suggestion how could I proceed with the implementation.