(require 'prodigy)

(prodigy-define-tag :name 'rails
  :ready-message "Listening on 0\\.0\\.0\\.0:[0-9]+, CTRL\\+C to stop")

(prodigy-define-tag
  :name 'zeus
  :on-output
  (prodigy-callback (service)
    (let ((poll-zeus "ps aux | grep -c 'zeus slave:'"))
      (when (>= (string-to-number (shell-command-to-string poll-zeus)) 6)
        (prodigy-set-status service 'ready)))))

(prodigy-define-tag :name 'resque-pool
  :ready-message "Starting worker")

(prodigy-define-tag :name 'resque-scheduler
  :ready-message "Schedules Loaded")

;; ansi-color-apply and filter were causing out-of-range errors for zeus
(setq prodigy-output-filters (remove 'ansi-color-apply prodigy-output-filters))

(provide 'clgc-prodigy)

(require 'prodigy)

(prodigy-define-tag :name 'rails
  :ready-message "Listening on 0\\.0\\.0\\.0:[0-9]+, CTRL\\+C to stop")

(prodigy-define-tag
  :name 'zeus
  :command "/bin/bash"
  ;; Strip zeus start of color codes to prevent ansi out-of-bound errors
  :args '("-c" "zeus start | sed \"s,\x1B\[[0-9;]*[a-zA-Z],,g\"")
  :stop-signal 'sigkill
  :kill-process-buffer-on-stop t
  :on-output
  (prodigy-callback (service)
    (let ((poll-zeus "ps aux | grep -c 'zeus slave:'"))
      (when (>= (string-to-number (shell-command-to-string poll-zeus)) 6)
        (prodigy-set-status service 'ready)))))

(prodigy-define-tag :name 'resque-pool
  :ready-message "Starting worker")

(prodigy-define-tag :name 'resque-scheduler
  :ready-message "Schedules Loaded")

(provide 'clgc-prodigy)

Fix problems with ansi-escape in zeus start
Fix problems with ansi-escape in zeus start

Moves command into tag. Still has a problem on shutdown but I think it's
in prodigy detecting shutdown correctly, not zeus failing to stop. It
cleans up after itself at any rate.

dgtized/dotfiles,dgtized/dotfiles,dgtized/dotfiles