Last active
March 30, 2017 22:11
-
-
Save abrookins/abd7e84b285353a0262f6f626dddade4 to your computer and use it in GitHub Desktop.
Restart fastkit with Hammerspoon when DNS changes
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local network = hs.network.configuration.open() | |
local fastkitPath = '~/.rbenv/shims/fastkit' | |
local home = '/Users/andrew' | |
function fastkitCompleted(exitCode, stdOut, stdErr) | |
if exitCode ~= 0 then | |
hs.alert.show("Fastkit failed to reload") | |
log.d(stdOut) | |
end | |
end | |
function fastkitCallback(store, keys) | |
job = hs.task.new(fastkitPath, fastkitCompleted, {'restart', 'proxy'}) | |
job:setEnvironment({PATH='$PATH:/bin:/usr/bin:/usr/local/bin:/sbin', HOME=home}) | |
job:setWorkingDirectory('~/src/fastkit') | |
job:start() | |
end | |
network:monitorKeys('State:/Network/Global/DNS') | |
network:setCallback(fastkitCallback) | |
network:start() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment