Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial commit on compatible API #6

Merged
merged 5 commits into from
Nov 1, 2019
Merged

Initial commit on compatible API #6

merged 5 commits into from
Nov 1, 2019

Conversation

jwhonce
Copy link

@jwhonce jwhonce commented Nov 1, 2019

Signed-off-by: Jhon Honce jhonce@redhat.com

Signed-off-by: Jhon Honce <jhonce@redhat.com>

"github.com/containers/libpod/libpod"
log "github.com/sirupsen/logrus"

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove line

func NewServer(runtime *libpod.Runtime) (*HttpServer, error) {
listeners, err := activation.Listeners()
if err != nil {
log.Panicf("Cannot retrieve listeners: %s", err)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not return errors.Wrapf?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Panic is easier for now. Will move to errors once we wire everything in.

log.Panicf("Cannot retrieve listeners: %s", err)
}
if len(listeners) != 1 {
log.Panicf("unexpected number of socket activation (%d != 1)", len(listeners))
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not return errors.Errorf?

defer cancel()
server.SetKeepAlivesEnabled(false)
if err := server.Shutdown(ctx); err != nil {
log.Panicf("cannot gracefully shut down the http server: %s", err)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't we just log.Errorf?

func (s *HttpServer) Serve() error {
err := http.Serve(s.listener, nil)
if err != nil {
log.Panicf("Cannot start server: %s", err)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Return errors.Wrapf

Use cd cmd/service && go build .

$ systemd-socket-activate -l 8081 cmd/service/service &
$ curl http://localhost:8081/v1.24/images/json

Signed-off-by: Jhon Honce <jhonce@redhat.com>
Signed-off-by: Jhon Honce <jhonce@redhat.com>
Signed-off-by: Jhon Honce <jhonce@redhat.com>
Signed-off-by: Jhon Honce <jhonce@redhat.com>
@baude baude merged commit da8ec26 into baude:apiv2 Nov 1, 2019
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 12, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants