add "is_running(service)" to Container
See original GitHub issueTo check if a service is running we need to:
self.container.get_service("service_name").is_running()
Recently Container.restart(services)
was added and Container.is_running(service)
would be a great companion.
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (5 by maintainers)
Top Results From Across the Web
How to automatically start a service when running a docker ...
First, there is a problem in your Dockerfile : RUN service mysql restart && /tmp/setup.sh. Docker images do not save running processes.
Read more >Check is container/service running with docker-compose
This doesn't tell you if the container is running or not, just if it exists or not. Try doing docker-compose up then Ctrl-C....
Read more >docker service create - Docker Documentation
Create a service with a config. The config will be mounted into redis-config , be owned by the user who runs the command...
Read more >Chapter 4. Running Containers as systemd Services with ...
When you set up a container to start as a systemd service, you can define the order in which the containerized service runs,...
Read more >Attach to a running container - Visual Studio Code
To attach to a Docker container, either select Dev Containers: Attach to Running Container... from the Command Palette (F1) or use the Remote...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
ops.pebble
is explicitly part of the operator framework.ops.model
andops.framework
wrap a fair amount of things. It isn’t necessarily about talking to pebble directly (whichcontainer.get_service("service_name").is_running()
is not doing either, by the way), and more about encapsulation.ops.pebble.Service
is the representationget_service
returns, and whether or not it’s running depends checks againstops.pebble.ServiceStatus
.Logically, a
Container
may have many services.is_running("service_name")
reads akin to “each service has its own container”. If anything,Container.get_service_status("service")
would make more sense, but then we’re simply re-exporting an enum fromops.pebble
and re-implementing the same logic (either punting it to charm authors or moving it up a level and duplicating it inops.model
) unless it calls exactly the same code in your original comment, orself.get_service("service_name").is_running()
, really.I do not recall encountering charm code that talks to pebble directly. To my understanding,
ops.model
servers as a wrapper around anything pebble (cf.container.pull
).It is true though that
start, stop, restart
all have the same “directionality” to them (OF -> Pebble).The
container.is_running()
interface could deal with that, e.g.if all/any(container.is_running(lst))
etc.