portler restart
Restart services in the background.
bash
portler restart [docker] [service...] [--prod] [--setup|--no-setup] [--image <service>=<image>] [--volume-set <name>]Behavior
- Stops the named services (all by default) and starts them again detached, like
up -d. - Restarted services keep their previously assigned ports whenever they are still free.
portler restart apirestarts a single service: dependencies that are not running are started too; running ones are left untouched. Running means whatportler psreports as running: a Docker dependency whosedocker runprocess is gone but whose container runs on counts, and so does one whose container cannot be inspected, rather than having its container replaced.portler restart docker apirestarts in Docker mode.- Without flags,
restartreplays how the services were started.pids.jsonrecords, per service, whether it was started with--prod, in which run mode (dockeror plain), with which--imagepin, whether with--no-setup, and, for a container that mounts a managed volume, from which--volume-set. A routineportler restart apion a production Docker stack therefore comes back as a production container, from the same pinned image, without running setup steps, and a database started on--volume-set branchcomes back on that set's volumes, not the base ones. For a container started by an older Portler, which did not record the set, the set is read from the volumes the container mounts at its@paths; if that cannot be read, a volume at one of those paths is not this project's@volume of that name, or the container still mounts that@volume at a path the config has since changed, the restart is refused before anything is stopped and asks for--volume-set, ordownfirst to start on the base volumes. The noticerestart keeps the recorded launch: ...says what was replayed. - Flags override, for the services the restart starts again.
--prodrestarts with the production overrides likeup --prod;dockerrestarts in Docker mode;--image <service>=<image>replaces a recorded pin (prebuilt images);--setupforces the plain setup steps and--no-setupskips them (receipts are still reconciled);--volume-set <name>(orPORTLER_VOLUME_SET) mounts that set for every service the restart starts. A recorded pin that does not apply in the chosen run mode is dropped with a notice. - What the restart leaves running has to agree. A dependency left running in the other mode (development next to a production restart, or the reverse), or started in the other run mode, is refused before anything is stopped, naming it. Restarting everything (
portler restart --prodwith no names) may switch the whole stack, since nothing is left behind; so maydownand thenup. A stack whose recorded services mix the two modes cannot be replayed and needs the flag. Setup is one choice for the whole restart, so the same holds when the recorded services it starts again (a dead dependency that comes back included) were started some with--no-setupand some without: pass--setupor--no-setup. The volume set is one choice too: containers it starts again that were mounted from different sets are refused, naming each; pass--volume-setor restart them separately. - A restart without names stops every recorded service, including ones removed from the config since they started, and replays their mode for the current config.
- A replayed
--prodnarrows toprod.serviceslike a typed one: a service it leaves out is the deployment's, so a development copy of it that happens to be running is neither stopped, started nor counted when the mode to replay is decided. It narrows toprod.servicesas they are now: a service recorded with--prodthat has since been dropped from them is refused by name, asrestart --prodrefuses it, before anything is stopped. - With
--prod, typed or replayed,prod.requireis checked before anything is stopped, so a deployment value that has gone missing leaves the running services up instead of taking them down and failing to start them again. - The launch is checked against the current config before anything is stopped too: a replayed Docker mode for a service whose
docker:block has since been removed, a service with neither a command nor Docker config, or an--imagethe run mode cannot use is refused while the services are still up. - A running dependency that exits on its own while the restart is stopping the requested services is started again with them, and with its own recorded launch: the restart plans again from what is running after the stop, so the dependency's record takes part in the choices above and the same checks run. If its record disagrees with the rest (for example, it was started with
--no-setupand they were not), the restart stops there and says so; the requested services are then stopped and nothing has been started.
No Kubernetes mode
portler restart k8s is rejected, and so is a plain portler restart of anything portler up k8s started, before anything is stopped. Restarting a Kubernetes stack has to re-apply manifests and re-establish port-forwards, which restart does not do. Run the two steps instead:
bash
portler down k8s && portler up k8s(Earlier versions accepted restart k8s and quietly did the wrong thing: they applied the Kubernetes config overlay — in-cluster DNS hostnames and k8s.env — and then ran the services as local processes, never touching the cluster.)
Examples
bash
portler restart # restart everything, detached
portler restart backend # restart one service
portler restart docker api # restart in Docker mode
portler restart api --prod # restart in production mode (a plain restart keeps it)
portler restart --no-setup # restart without running setup steps (receipts are still reconciled)
portler restart --prod # switch a whole development stack to production