rejeep / prodigy.el

Manage external services from within Emacs
GNU General Public License v3.0
550 stars 39 forks source link

:init does not work with (prodigy-callback ...) #70

Open thomasf opened 9 years ago

thomasf commented 9 years ago

Is it intended or just overlooked?

My use case right now is adding a build step to build a binary before launching it.

rejeep commented 9 years ago

Is the build step sync or async?

thomasf commented 9 years ago

The following modification enables it but I'm not comfortable enough with the code to create a pull request and there are still bugs in my related code..

      (-when-let (init (prodigy-service-init service))
        (prodigy-callback-with-plist init service)
        ;; (funcall init service)
        )
thomasf commented 9 years ago

Given the minor patch above the following seems to work alright now.

(eval-after-load "prodigy"
  '(progn
     (prodigy-define-tag
       :name 'bin
       :hide t
       :path (lambda ()
               (file-truename default-directory)))

     (defun prodigy-go-build (service)
       (prodigy-insert-output
        service
        "- - - - - - - - - - - - - - - - - - - - - -\n")
       (let ((cmd (plist-get service :command)))
         (when (file-exists-p cmd)
           (delete-file cmd))
         (with-temp-buffer
           (let ((success (eq 0 (call-process "go" nil t nil "build"
                                              "-o"  cmd (plist-get service :go-main)))))
             (prodigy-insert-output service (buffer-string))
             (unless success
               (error "prodigy-go-build-failed"))))))

     (prodigy-define-tag
       :name 'go-build
       :hide t
       :init  (prodigy-callback (service) (prodigy-go-build service))
       :tags '(bin))

     (prodigy-define-service
       :name "project01 central"
       :cwd "/home/a00001/repos/go/src/gitlab.aOrganisation.se/project01/project01"
       :command "project01-central"
       :args '("-logtostderr" "-v=10")
       :go-main "cmd/project01-central/project01-central.go"
       :kill-signal 'sigkill
       :tags '(project01 go-build))

     (prodigy-define-service
       :name "project01 client"
       :cwd "/home/a00001/repos/go/src/gitlab.aOrganisation.se/project01/project01"
       :init  (prodigy-callback (service) (prodigy-go-build service))
       :command "project01-client"
       :go-main "cmd/project01-client/project01-client.go"
       :kill-signal 'sigkill
       :tags '(go-build project01))

     (prodigy-define-service
       :name "project01 hot"
       :cwd "/home/aUser/repos/go/src/gitlab.aOrganisation.se/project01/project01"
       :go-main "make.go"
       :command "make"
       :args '("hot")
       :kill-signal 'sigkill
       :tags '(project01 go-build))))