feat(bkgpslog):Force ordered write operations with wait
[EVA-2020-02.git] / exec / bkgpslog-plan.org
... / ...
CommitLineData
1* bkgpslog task list
2** DONE Add job control for short buffer length
3 CLOSED: [2020-07-02 Thu 16:04]
42020-07-02T14:56Z; bktei> File write operations were bundled into a
5magicWriteBuffer function that is called then detached from the script
6shell (job control), but the detached job is not tracked by the main
7script. A problem may arise if two instances of magicWriteBuffer
8attempt to write to the same tar simultaneously. Two instances of
9magicWriteBuffer may exist if the buffer length is low (ex: 1 second);
10the default buffer length of 60 seconds should reduce the probability
11of a collision but it should be possible for the main script to track
12the process ID of a magicWriteBuffer() as soon as it detaches and then
13checking (via ~$!~ as described [[https://bashitout.com/2013/05/18/Ampersands-on-the-command-line.html][here]]) that the process is still alive.
142020-07-02T15:23Z; bktei> I found that the Bash ~wait~ built-in can be
15used to delay processing until a specified job completes. The ~wait~
16command will pause script execution until all backgrounded processes
17complete.
182020-07-02T16:03Z; bktei> Added ~wait~.
19* bkgpslog narrative
20** Initialize environment
21*** Init variables
22**** Save timeStart (YYYYmmddTHHMMSS±zz)
23*** Define Functions
24**** Define Debugging functions
25**** Define Argument Processing function
26**** Define Main function
27** Run Main Function
28*** Process Arguments
29*** Set output encryption and compression option strings
30*** Check that critical apps and dirs are available, displag missing ones.
31*** Set lifespans of script and buffer
32*** Init temp working dir ~DIR_TMP~
33Make temporary dir in tmpfs dir: ~/dev/shm/$(nonce)..bkgpslog/~ (~DIR_TMP~)
34*** Initialize ~tar~ archive
35**** Write ~bkgpslog~ version to ~$DIR_TMP/VERSION~
36**** Create empty ~tar~ archive in ~DIR_OUT~ at ~PATHOUT_TAR~
37
38Set output file name to:
39: PATHOUT_TAR="$DIR_OUT/YYYYmmdd..hostname_location.gz.age.tar"
40Usage: ~iso8601Period $timeStart $timeEnd~
41
42**** Append ~VERSION~ file to ~PATHOUT_TAR~
43
44Append ~$DIR_TMP/VERSION~ to ~PATHOUT_TAR~ via ~tar --append~
45
46*** Read/Write Loop (Record gps data until script lifespan ends)
47**** Determine output file paths
48**** Define GPS conversion commands
49**** Fill Bash variable buffer from ~gpspipe~
50**** Process bufferBash, save secured chunk set to ~DIR_TMP~
51**** Append each secured chunk to ~PATHOUT_TAR~
52: tar --append --directory=DIR_TMP --file=PATHOUT_TAR $(basename PATHOUT_{NMEA,GPX,KML} )
53**** Remove secured chunk from ~DIR_TMP~