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

Auto start #38

Open
rejeep opened this issue Jan 19, 2014 · 6 comments
Open

Auto start #38

rejeep opened this issue Jan 19, 2014 · 6 comments

Comments

@rejeep
Copy link
Owner

rejeep commented Jan 19, 2014

This is an idea about adding a new property called :auto-start. If that is set to true, the service will automatically start when it's defined.

For example:

(prodigy-define-service
  :name "Rails App"
  :command "bundle"
  :args '("exec" "rails" "server")
  :cwd "/path/to/my/project"
  :auto-start t)
@zeltak
Copy link

zeltak commented Jul 2, 2017

any progress on that? so currently after each emacs restart i need to issue M-x prodigy, and go to the process and issue M-x prodigy-start?

@seblemaguer seblemaguer mentioned this issue Dec 3, 2017
3 tasks
@tosmi
Copy link

tosmi commented Nov 1, 2018

i would be great if you could merge #106. i moving my systemd/launchd stuff over to prodigy and auto start would be really helpful.

thanks

@isamert
Copy link
Contributor

isamert commented Jun 30, 2022

I wrote the following snippet for adding a primitive auto-start feature that fits my needs, if anyone is interested:

(defun isamert/prodigy-autostart ()
  "Start all services with the `:auto-start' set to non-nil if they
are not already started."
  (interactive)
  (prodigy-with-refresh
   (--each
       prodigy-services
     (when (and (plist-get it :auto-start)
                (not (prodigy-service-started-p it)))
       (prodigy-start-service it)))))

(add-hook
 'after-init-hook
 #'isamert/prodigy-autostart)

You need to add :auto-start t to service definitions as described in the first comment. You can also call isamert/prodigy-autostart anytime if you want to start services that are marked :auto-start manually if you want.

@isamert
Copy link
Contributor

isamert commented Jun 30, 2022

Now that I think of this, I can prepare a PR with the following function (and with some documentation regarding to it)

(defun prodigy-autostart ()
  "Start all services with the `:auto-start' set to non-nil if they
are not already started."
  (interactive)
  (prodigy-with-refresh
   (--each
       prodigy-services
     (when (and (plist-get it :auto-start)
                (not (prodigy-service-started-p it)))
       (prodigy-start-service it)))))

and we can advise users to add this function to a some hook they see fit to get a basic auto-start feature going (and maybe we can advertise the after-init-hook at the documentation for this purpose like I did on the previous comment). Would you be interested in an PR like this @rejeep @DamienCassou? Maybe I can work on a more complex and complete solution in the future but I believe this cuts it for the most cases.

@Fuco1
Copy link
Collaborator

Fuco1 commented Jul 2, 2022

The PR #106 did a lot of work on this including tests and documentation. The basic logic is similar to yours but there's some additional settings etc. I say we should finish that one. Would you like to pick it up and test if it covers your use-case?

@isamert
Copy link
Contributor

isamert commented Jul 2, 2022

I saw that PR and I even tried to patch my local prodigy copy with it but it failed as some file names are changed etc. Then I saw that it's from 4 years ago and thought it's probably easier to define a function like the one above and call it a day instead of trying to rebase it with the current master. I may look into cleaning that PR but I don't know when I would pick this task up.

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

5 participants