I have a method getThumbnailPath which returns the path to a preview image, as presented TTW (/++thumbnail++/UID); when the catalog metadata of an object is refreshed, the thumbnail image is checked and, if necessary, (re)created. The /++thumbnail++/ URLs are excluded from the RewriteRule, and DocumentRoot/++thumbnail++ is a symbolic link to var/thumbnails.
Now I noticed that there is some surprising difference between my development and production servers: In the development setup, the working directory (os.getcwd()) is the instance directory (which contains the parts/), while in the productive setup (using systemctl start myproject.service), it is parts/instance. This yielded some surprising effects - my thumbnails generation didn't seem to work, while they indeed have been created - just not at the place where Apache expected them.
Is there some "official way" to get the absolute location of the var/ and log (normally var/log, but who knows ...) directories, or should I write my own? I'd like to avoid code differences between the both if at all possible.
Just as a quick pointer for inspiration for your project, check the code in eea.downloads, which is an add'on made by Eaudeweb for the European Environment Agency. It's a helper add'on to prepare and write unique downloads outside the zodb in the var directory which can then be downloaded (albeit through Plone itself).
There's little context in your question, but you do know that Plone has quite extensive support for generating and storing and refreshing cachable image scales on image fields in contenttypes, right? Just checking.
AFAICS, eea.downloads simply uses environment vars EEADOWNLOADS_{NAME,PATH} for initialisation; no special Zope/Plone examiniation here. Or did I overlook something?
Good idea; this will work for most setups, including mine.
Unfortunately, it is possible to configure the pid file location to be elsewhere, and I can imagine there are valid reasons to do so. Thus, since we don't have anything better (apart from environment variables, but those should be strictly optional IMHO), an official way would be something to be established ...