Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flexible services shutdown options #22

Closed
yveszoundi opened this issue Dec 19, 2013 · 4 comments
Closed

Flexible services shutdown options #22

yveszoundi opened this issue Dec 19, 2013 · 4 comments

Comments

@yveszoundi
Copy link

I think that it would be useful to have the following features:

  • auto-close-service-buffer-on-stop to close the prodigy-service-name buffer if the service-name is stopped.
  • stop-service-hook in the same spirit of init-async? If bound, then call the hook after sending the signal?

Below is an example of what I use with Tomcat. When I stop the service, ideally I want to close the "prodigy-tomcat" buffer automatically. Thus a auto-close-service-buffer-on-stop parameter that defaults to t would be convenient.

(use-package prodigy                                                                                                                          
  :ensure prodigy                                                                                                                             
  :config (progn                                                                                                                              
            (prodigy-define-service                                                                                                           
              :name "Tomcat"                                                                                                                  
              :command "./catalina.sh"                                                                                                        
              :cwd "/Users/yves/Tools/apache-tomcat-7.0.25"                                                                                   
              :path '("/Users/yves/Tools/apache-tomcat-7.0.25/bin")                                                                           
              :port 8080                                                                                                                      
              :stop-signal 'SIGTERM                                                                                                           
              :args '("run")                                                                                                                  
              :tags '(java))))                                                                                                                                                        

Thanks

@yveszoundi
Copy link
Author

I'm currently using an advice to auto-close services buffer

(defadvice prodigy-stop-service                                                                                                               
    (after prodigy-stop-service-close-buffer (service) activate )                                                                             
  "Close prodigy service buffer after the stop call."                                                                                         
  (let* ((service-name-downcased (downcase (plist-get service :name)))                                                                        
         (service-buffer-name (concat "*prodigy-" service-name-downcased "*")))                                                               
    (when (get-buffer service-buffer-name)                                                                                                    
      (kill-buffer (get-buffer service-buffer-name))))) 

@rejeep
Copy link
Owner

rejeep commented Dec 19, 2013

I think a global variable (for example prodigy-kill-process-buffer-on-stop) is a good idea. But I also think it makes sense that this can be specified per service, hence override the global setting.

For example:

(prodigy-define-service
  :name "foo"
  :kill-process-buffer-on-stop t
  )

I've been thinking of hooks as well, but that's not just related to stop. That would make sense for start and restart also for example.

(prodigy-define-service
  :name "foo"
  :after-stop (lambda ()
                (kill-buffer ...)
                ))

Another configuration that might be useful is prodigy-erase-process-buffer-on-start, so that if the process have been started before, the contents is cleared.

What do you think?

@yveszoundi
Copy link
Author

That sounds perfectly reasonable to me, especially in the early stages of the project.

Issue #3 is kind of related. When providing services definitions, users should be able to provide a way to ensure that the desired action has completed with the expected side-effect, if needed (Tomcat started but not ready yet, WebRick stop initiated but not completed, etc.).

If the signal sent to terminate a program is a SIGKILL, there's no need for extra logic. In most cases, I think that a SIGTERM will be used to allow programs to shutdown gracefully without creating any kind of state/db corruption.
Therefore the action should complete successfully prior to calling any hook.

@rejeep
Copy link
Owner

rejeep commented Dec 20, 2013

Closing this issue in favor of #24 and #25.

@rejeep rejeep closed this as completed Dec 20, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants