Project Manager.

Project Manager makes it easier to keep track of your micro-services by grouping together related services; stop/start/build and set dependencies.

Article image for: Project Manager

Working with Services.

Introduction
Getting Started
Projects
Working with Services
Setting Config Options
Scripting Setup

Github Print

Working with services

Starting

spm provides several wrappers to help with starting / stopping and getting an overview of the current projects services. All services commands are prefixed with services:. Once you have added some services you can list them: spm services:list and then start one or more: spm services:start service1 service2 service3 or start all of the services: spm services:start all. services:start is aliased to start

If you have defined dependencies and have not specified either -d to automatically start dependencies, or -D to not start dependencies; you will be prompted if you wish to start the dependencies first or not. If you opt to start services, then all dependencies will be resolved and started first. You will not be prompted again after being asked the first time.

Status Overview

To get an overview of the current project services: spm services:status. This will query Docker to get assorted data about all containers that match the preset compose name from the project config and display the information in a table. This information includes:

  • running container name
  • current status (up/down etc)
  • the host if it has been set e.g. for traefik or the IP for the external DB connection
  • external port(s)
  • any volumes connected to the container

The status output is in a CLI table by default, however it can also be generated as:

  • CSV
  • JSON
  • pipe separated, plain text

Add --format=csv|json|plain to get the desired output.

If SyncIt is installed and setup on a service; the current status will be output with the spm status information. Note: this adds an amount of overhead and can take a few seconds to display for many running containers. To disable syncit checks, add --no-syncit.

Stopping

To stop a service use: spm services:stop service1 service2 or spm services:stop all to stop all running services. Services that have dependencies will automatically cause dependent services to be stopped as well. For example: if you have a main data service that provides databases, and your apps depend on this; when you stop the service, then all the dependent services will be stopped first. services:stop is aliased to stop.

If syncit is installed and there are active sync sessions, they will be stopped before the container the service is stopped.

Logs

The docker logs can be viewed by running: spm services:log service or use the alias log. Add -f to follow the log and use Ctrl+C to stop. This is the same output that you can get from: docker-compose log <container-name>.

Rebuilding / cleaning the docker containers

If you encounter major issues with your containers or just want to reset to a completely clean state, either use: docker system prune --all --volumes or spm services:reset. The spm command calls the same options under-the-hood.

For less drastic rebuilds, the services:start command allows for:

  • --rebuild / -b - rebuild containers and then start
  • --refresh / -r - refresh and start

The difference between build and refresh is that refresh will force pull any new images as well as rebuild the container images. Use this if the upstream image has been updated and you need a new version instead of the cached version.

Copy files to/from containers

You can easily copy files to/from your running containers by using: spm services:copy that is aliased as copy and cp. Note: that one side of this command must be a service name specified as service_name:/path/in/container.

The format is: spm services:copy source target, for example to copy a file from your downloads into the users-app container, configured as users:

spm services:copy ~/Downloads/file.txt users:/app/tmp/file.txt

Under-the-hood, services:copy uses docker cp.

Note: the copy command uses the service name; not the actual docker container name!

Note: the copy command uses the current working directory and not the services path when it is running. Run spm services:copy -h for help and the current working folder.