Automatic S3 Uploads (Mac Mini)
The Mac Mini in the studio has been configured to automatically upload sets placed into the shoots folder on the currently in use drive.
Watchman has been set up on the Mac Mini under the “andrew” user to watch:
/Volumes/Drive 50/shoots/
and to then call the AWS CLI to upload and new files using the sync option. The watchman configuration is in:
/Users/andrew/watchman-upload-s3.json
and if updated needs to be re-registered with the watchman service using the command:
watchman -j < watchman-upload-s3.json
It should respond with some JSON and part of it should say:
"disposition": "replaced"
To show it has been updated. If it responses with:
"disposition": "already_defined"
It means nothing has been changed.
You can view the current watches using the following command:
watchman watch-list
If you need to delete a watch, you can do it using the following command:
watchman watch-del "[path_to_watch]"
for example:
watchman watch-del "/Volumes/Drive 53/shoots"
The watchman service should start automatically on boot, but as it runs under the user, I think it might only start once the user has logged in.
The output from the AWS CLI calls are placed into the watchman log file, which can be found at:
/usr/local/var/run/watchman/andrew-state/log
so you can do:
cat /usr/local/var/run/watchman/andrew-state/log
or:
tail -f /usr/local/var/run/watchman/andrew-state/log
to view the log file.
Newer version of watchman
When putting on a new drive, you have to “register” the directory with watchman first by going into the directory and running:
watchman watch ./
and once you have done this you can run the command:
watchman -j < watchman-upload-s3.json
from the home directory to add the watch trigger.
Reference links:
https://github.com/facebook/watchman
https://facebook.github.io/watchman/
https://docs.aws.amazon.com/cli/latest/reference/s3/sync.html
https://github.com/facebook/watchman/issues/662
