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

Feature request: command to remove or edit a service #2

Open
lahwran opened this issue Jul 5, 2021 · 6 comments
Open

Feature request: command to remove or edit a service #2

lahwran opened this issue Jul 5, 2021 · 6 comments

Comments

@lahwran
Copy link

lahwran commented Jul 5, 2021

Hey AJ! Nice to run into your work on the internet again. I used serviceman to set up syncthing, but now I want to edit the command, and it seems I'm going to have to reach under syncthing to edit the systemd service directly. Not a huge deal, but would be nice to also have the commands to remove or overwrite a service built-in.

-- Lauren

@ryanburnette
Copy link
Contributor

I agree.

@ryanburnette
Copy link
Contributor

Aj needs to move the old issues here https://git.coolaj86.com/coolaj86/go-serviceman/issues/3

@coolaj86
Copy link
Contributor

Hi Lauren,

I'm not clear on what you mean. Are you saying that you want to be able to list and remove services that weren't added by serviceman?

@lahwran
Copy link
Author

lahwran commented Jul 12, 2021

no, I'm saying that I want to be able to remove/overwrite services that were added by serviceman, because I don't see a command to do that in the docs or code, unless I missed something.

Relatedly, question I forgot to test the other day and so I'm noting here until I can investigate this myself - is add:

  1. idempotent because it's a noop if the service exists,
  2. idempotent because it's a noop if service CLI config is unchanged,
  3. or not idempotent because eg it always restarts the service

Other musings, to give context as to how I came to use serviceman and create this issue:

The use case here is that ultimately I'd like to be able to use serviceman to install a user service automatically as part of a redo build target, and have that be close to the same development experience as launched-by-the-devtools development. to do that I need a way to overwrite-and-restart the service, which I would then run as something vaguely like:

npx concurrently \
    'watchexec $WATCHEXEC_IGNORE_CONFIG ./reinstall_serviceman.sh' \
    'tailfollow_serviceman_logs.sh'

(but with a lot more package version locking.)

...hmmm, further tangenting off of this, perhaps I should look into how hard it would be to modify webi to install into a virtualenv/node_modules style vendor directory... I'd also love a way to redirect stdio to a file in all cases to make tailfollow_serviceman_logs.sh a simpler script, perhaps just by modifying what I tell serviceman to launch, or maybe modify the systemd config somehow, does systemd support that? hmm...

as you can see, my thoughts on the project that needs this are not very clear right now and I have plenty of workaround options available. sor what it's worth, I see this feature as much as a "todo someday" for myself as it's a feature request for y'all. Triage according to taste, not based on any feeling of urgency from me. good chance I'll just work around it using an approach that looks vaguely like the above sketch. maybe I could even use serviceman to generate the installable thing that goes into publishable packages!

@coolaj86
Copy link
Contributor

coolaj86 commented Jul 17, 2021

@lahwran Thanks for the clarification.

I agree. This should have a remove. I'd accept a PR for that, and otherwise I do want to do it... eventually, when I can carve out the time for it.

I believe that add will always rewrite the existing service file and restart the service.

I'd be open for a PR that changes this to check if the file that would be written has the same hash as the existing file and, if so skips restarting. That would also need a --force flag to override.

@ryanburnette
Copy link
Contributor

I keep wanting this feature. Here's how I do it manually.

sudo systemctl stop myserv
sudo systemctl disable myserv
sudo rm /etc/systemd/system/myserv.service
sudo systemctl daemon-reload

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

3 participants