OSX launchctl,如何在卸载时停止工作

时间:2016-10-03 12:23:38

标签: node.js macos launchd

目前我正在使用forever和LaunchAgent

启动aGhost npm服务器
    <?xml version="1.0" encoding="UTF-8"?>  
    <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">  
    <plist version="1.0">  
    <dict>  
        <key>KeepAlive</key>
        <dict>
            <key>SuccessfulExit</key>
            <false/>
        </dict>
        <key>Label</key>
        <string>rhino.forever.ghost</string>
        <key>ProgramArguments</key>
        <array>                              
          <string>..../bin/node</string>
          <string>..../bin/forever</string>
          <string>start</string
          <string>-w</string>
          <string>..../index.js</string>
        </array>
        <key>RunAtLoad</key>
        <true/>
    </dict>  
    </plist>  

从以下开始:

 launchctl load -w ~/Library/LaunchAgents/rhino.forever.ghost.plist

但卸货时它并没有停止:

 launchctl unload  ~/Library/LaunchAgents/rhino.forever.ghost.plist

无论如何在卸货时停止它

感谢您的反馈

1 个答案:

答案 0 :(得分:0)

我决定开始|停止|重启我的幽灵应用程序&#39; rhino&#39;使用.bash_aliases中的别名

alias rhino.dev.start="nginx.start; 
  cd /Users/..../myghostapp;
  ~/.../bin/forever start -aw --uid 'rhino' index.js; 
  forever list"

alias rhino.dev.stop="forever stop 'rhino' ; nginx.stop"

alias rhino.dev.restart="forever restart 'rhino' ; nginx.restart"

现在正常运行