Comments (6)
Hi @LukasKnuth, thank you for reporting this.
Sorry to hear you had an issue with the healthcheck. This was fixed in v0.34.0 of the CLI, which was released in Imposter 3.31.6, released on 26/10/23.
Using current build:
$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
d89a494d4d1d outofcoffee/imposter:3.36.0 "java -classpath /op…" 14 seconds ago Up 13 seconds 0.0.0.0:8080->8080/tcp, 8443/tcp peaceful_carson
$ docker exec -it d89 imposter list -x
| ID | NAME | PORT | HEALTH |
|----|------|------|---------|
| 1 | java | 8080 | healthy |
$ echo $?
0
For completeness - an unhealthy example:
$ docker exec -it $( docker ps -q ) imposter list -x ; echo $?
ERRO[0000] healthcheck request failed for mock: healthcheck request failed for mock at http://localhost:8080/system/status: Get "http://localhost:8080/system/status": dial tcp 127.0.0.1:8080: connect: connection refused
| ID | NAME | PORT | HEALTH |
|----|------|------|-----------|
| 1 | java | 8080 | unhealthy |
1
from imposter.
Hi @LukasKnuth, thanks for raising this.
Yes, you can use the /system/status
healthcheck endpoint which returns HTTP 200
when the server is up.
For additional binaries inside the container, here's an example of a custom Docker image https://github.com/outofcoffee/imposter/blob/main/examples/docker/Dockerfile
☝️ This example extends from the Java base image so has its various userspace tools available (and more you can install with the package manager).
from imposter.
For this part of your question:
Would you be open to adding a CLI option to the server to check if its up and ready?
You should be able to use this command with the CLI:
imposter list --exit-code-health
You can also use the short form of the
--exit-code-health
argument,-x
More info here.
This sets the exit code based on mock health.
Example
$ imposter list -x ; echo $?
| ID | NAME | PORT | HEALTH |
|----|------|------|--------|
1
☝️ Returns code 1 as no mocks running.
$ imposter list -x ; echo $?
| ID | NAME | PORT | HEALTH |
|--------------|--------------|------|---------|
| d5755b211011 | /brave_mayer | 8080 | healthy |
0
☝️ Returns code 0 as a healthy mock running.
from imposter.
Nice, thanks for getting back to me. I wasn't aware that this existed already, thats great!
from imposter.
I tested it with my setup now and for me, this doesn't seem to work as expected:
$ docker exec e2e-apiv1-1 imposter list -x
| ID | NAME | PORT | HEALTH |
|----|------|------|---------|
| 1 | java | 0 | unknown |
$ echo $?
1
I use the openapi
plugin for this. Everything in the mock works as expected, just the list returns the unknown
health status. Do I need to add any additional information to the configuration for imposter ls
to pick it up and/or it's health?
from imposter.
If somebody ends here via search: One can configure a healthcheck with docker-compose like this:
healthcheck:
test: ["CMD", "imposter", "list", "-x"]
interval: 3s
timeout: 10s
retries: 5
from imposter.
Related Issues (20)
- [Question] How can I serve WSDL file with SOAP plugin ? HOT 2
- NPE while parsing a WSDL with rpc/encoded style HOT 2
- Precompiling js script files fails from docker container HOT 6
- SOAP : WSDL with includes fails parsing HOT 1
- Autoreload when using docker and config files change HOT 2
- Support for RPC style SOAP services HOT 2
- Support XML attributes in SOAP request body XPath
- Unable to format data from store as JSON in javascript script handler HOT 11
- SQS plugin
- Scheduled steps
- SOAP: WSDL with targetNamespace and messages without namespace prefix parsing issue
- Plugin index file
- imposter-3.22.0.jar - REST request with content-type=multipart/form-data - how to access the parts ? Groovy script returns null body HOT 1
- Unable to match multiple values in request body using XPath in SOAP plugin HOT 5
- "Docker Official Image" on docker hub
- [QUESTION] Configuration example for providing security config for individual plugins and swagger UI HOT 2
- Trivy reports lots of vulnerabilities HOT 2
- Possibility to configure list params
- Nashorn Load no longer working with Graal HOT 2
- Enforce client version through User-Agent header HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from imposter.