A service either serves network requests through endpoints for public access over the Internet(Web Service) or serves other services in the environment(Worker) via Middleware or direct HTTP requests.
Each Service in the Stack runs the same version of the code and launches Processes of the built source code in the stack specific command of your choosing.
Each Service can launch the source code in different ways; the following command prepares the
worker to run the app with the
mesh svc update worker --command "app queue"
web service launches the HTTP server:
mesh svc update web --command "app server"
Note: Services may fail to launch the command specified in the Service, to debug any problem with your Service see Monitoring and Debugging.
Here’s a list of abilities of a Service:
- Connect to the Internet
- Connect to Databases and Distributed Queues
- Make outbound requests to the Internet
- Receive inbound requests from other services in the same environment.
There are only two types of services: Workers and Web Services.
A worker is a service that does not service Inbound traffic from the Internet; as soon it’s bound to any Endpoint, it becomes a Web Service.
A web service is any service published through an Endpoint from the Environment, typically the Service in the Stack that contains the user-facing API or Web Application is a web service.
Example, assuming the environment platform alias is
https://top.widemesh.dev you can publish the service
web as follows:
mesh svc publish worker --endpoint https://top.widemesh.dev
A Web Service can be reverted to a Worker with
mesh service unpublish:
mesh svc unpublish worker --endpoint https://top.widemesh.dev
Each Service in the environment contains a Hostname that load balances between the healthy Instances of the Service, which is pretty useful for network-based micro-services, the format of the hostname format is as follows:
You have a service called
web inside the Stack
app, and it wants to make a
POST /payments request to the
payments service of the Stack
finance, it can use the following URL to perform HTTP requests:
Widemesh directs the HTTP request to any healthy Instance of the payment service.
Each Service in the Stack can be scaled independently to a user-defined number of Instances.
Example, the following command instructs Widemesh to launch five instances of the service
mesh svc update web --instances 5
Monitoring and Debugging
Service instances may crash after they start, they may run out of memory and not even start at all because the command contains a typo.
For that you can monitor the status of each Instance, the number of restarts, message, and exit codes of the Instances with
mesh service ls
You can get an interactive shell to a new instance of service with the following command:
mesh service run -n web -- /bin/bash
Note: Some docker base images such as
alpine do not feature
/bin/bash; you can use