This works via launchd, the blessed and proper approach on OS X, and is appropriate for an OSX worker running the worker daemon as a system service, launched at system boot.
If you are running your worker as the Desktop User (also known as "Desktop Worker" mode) which starts the worker when you log in, you don't need these, as the worker process is already set up to be shut down by launchd when you log out.
The attachment will contain 2 files:
-rw-r--r-- 0 root wheel 727 Aug 15 15:30 /Library/LaunchAgents/Many users have asked if we have scripts that would automatically lock the worker when a user logs in, and unlock it when they log out. Here's how.
- ensure that no other copies of
com.pipelinefx.WorkerLock.plist
exist in any of these directories:
/System/Library/LaunchAgents
/Library/LaunchAgents
or the user's ~/Library/LaunchAgents
directories
- install com.pipelinefx.WorkerLock.plist
...
- into
/Library/LaunchAgents
- install workerLock.py into
/Applications/pfx/qube/scripts
...
- fix the permissions on both of these files by running the following commands at a terminal prompt:
sudo chmod 644 /Library/LaunchAgents/com.pipelinefx.WorkerLock.plist
sudo chown root /Library/LaunchAgents/com.pipelinefx.WorkerLock.plist
sudo chgrp wheel /Library/LaunchAgents/com.pipelinefx.WorkerLock.plist
sudo chmod 755 /Applications/pfx/qube/scripts/workerLock.py
sudo chown root /Applications/pfx/qube/scripts/workerLock.py
sudo chgrp admin /Applications/pfx/qube/scripts/workerLock.py
- test the permissions and ownership:
ls -l /Library/LaunchAgents/com.pipelinefx.WorkerLock.plist /Applications/pfx/qube/scripts/workerLock.py
It should return something like:
-rwxr-xr-x@ 1 root admin 2721 Mar 28 13:43 /Applications/pfx/qube/scripts/workerLock.py
-rw-r--r-- 1 root wheel 685 Mar 28 13:00 /Library/LaunchAgents/com.pipelinefx.WorkerLock.plist
You're most interested in the values in the first column (the permissions for user, group, and other), and the owner (root) and group (admin or wheel).
Logout and back in to test, checking the worker lock status from another machine.