@@ -79,6 +79,14 @@ func (p *Proxy) Boot(ctx context.Context, settings ProxySettings) error {
7979 settings .MetricsPort = DefaultMetricsPort
8080 }
8181
82+ info , err := p .namespace .client .ContainerInspect (ctx , p .containerName ())
83+ if err == nil {
84+ return p .ensureRunning (ctx , info )
85+ }
86+ if ! errdefs .IsNotFound (err ) {
87+ return fmt .Errorf ("inspecting proxy container: %w" , err )
88+ }
89+
8290 reader , err := p .namespace .client .ImagePull (ctx , proxyImage , image.PullOptions {})
8391 if err != nil {
8492 return fmt .Errorf ("pulling proxy image: %w" , err )
@@ -181,6 +189,25 @@ func (p *Proxy) containerName() string {
181189
182190// Private
183191
192+ func (p * Proxy ) ensureRunning (ctx context.Context , info container.InspectResponse ) error {
193+ if ! info .State .Running {
194+ if err := p .namespace .client .ContainerStart (ctx , info .ID , container.StartOptions {}); err != nil {
195+ return fmt .Errorf ("starting proxy container: %w" , err )
196+ }
197+ }
198+
199+ label := info .Config .Labels [labelKey ]
200+ if label != "" {
201+ settings , err := UnmarshalProxySettings (label )
202+ if err != nil {
203+ return fmt .Errorf ("unmarshalling proxy settings: %w" , err )
204+ }
205+ p .Settings = & settings
206+ }
207+
208+ return nil
209+ }
210+
184211func (p * Proxy ) deployArgs (opts DeployOptions ) []string {
185212 args := []string {"kamal-proxy" , "deploy" , opts .AppName , "--target" , opts .Target , "--deploy-timeout" , deployTimeout }
186213
0 commit comments