opensafely-core / stata-docker

Builds the opensafely stata docker image.
0 stars 0 forks source link

Ensure Stata's default log output gets written to the container's stdout #3

Open evansd opened 3 years ago

evansd commented 3 years ago

Currently we run Stata in batch mode (with the -b flag). This causes it to write it's output to a log file named <script-name>.log and means that Stata jobs have effectively zero useful information in the default logs.

We should make sure that these logs get written to stdout somehow (in a streaming fashion, not as a batch at the end, so we can see what long running jobs are up to).

It's possible that we don't actually need the -b flag but we'll have to experiment to see what the behaviour is.

Whatever happens we'll still need our wrapper script to parse the log output to try to guess whether the job has errored as Stata helpfully exits with status zero in all cases.

bloodearnest commented 3 years ago

So, if we are running script.do, then if we do ln -sf /dev/stdout script.log before hand, then output is streamed to stdout

However, we then do not have a copy of the output to grep for error codes and exit with a non-zero error code.

bloodearnest commented 3 years ago

I think we can do this with named fifos. Fun!