{"id":13827109,"url":"https://github.com/crawshaw/littleboss","last_synced_at":"2025-04-04T18:05:58.185Z","repository":{"id":57488953,"uuid":"133369551","full_name":"crawshaw/littleboss","owner":"crawshaw","description":"littleboss: supervisor construction kit","archived":false,"fork":false,"pushed_at":"2019-03-17T18:56:09.000Z","size":69,"stargazers_count":637,"open_issues_count":3,"forks_count":16,"subscribers_count":15,"default_branch":"master","last_synced_at":"2025-03-28T17:06:31.084Z","etag":null,"topics":["golang","supervisor"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"isc","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/crawshaw.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-05-14T14:01:52.000Z","updated_at":"2025-03-04T10:16:03.000Z","dependencies_parsed_at":"2022-08-29T09:10:13.562Z","dependency_job_id":null,"html_url":"https://github.com/crawshaw/littleboss","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/crawshaw%2Flittleboss","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/crawshaw%2Flittleboss/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/crawshaw%2Flittleboss/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/crawshaw%2Flittleboss/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/crawshaw","download_url":"https://codeload.github.com/crawshaw/littleboss/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247226213,"owners_count":20904465,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["golang","supervisor"],"created_at":"2024-08-04T09:01:50.260Z","updated_at":"2025-04-04T18:05:58.163Z","avatar_url":"https://github.com/crawshaw.png","language":"Go","funding_links":[],"categories":["Go","golang"],"sub_categories":[],"readme":"# littleboss: self-supervising Go binaries\n\nA Go package, littleboss lets you turn your program into a\na self-supervising binary.\nIt starts itself as a child process, monitors its life cycle,\nreloads it if it exits, and can be instructed to replace it with\na new binary.\n\nThe supervisor can open sockets for you and share them across\nreloads of your program, ensuring no connections are dropped.\n\nYou can install it with:\n\n```\ngo get crawshaw.io/littleboss\n```\n\nMake a program use littleboss by modifying the main function:\n\n```go\nfunc main() {\n\tlb := littleboss.New(\"service-name\")\n\tlb.Run(func(ctx context.Context) {\n\t\t// main goes here, exit when \u003c-ctx.Done()\n\t})\n}\n```\n\nThe service name is used to identify which program the supervisor will control.\n\n## Usage\n\nBy default the supervisor is bypassed and the program executes directly.\nA flag, -littleboss, is added to the binary.\nIt can be used to start a supervised binary and manage it:\n\n```\n$ mybin \u0026                     # binary runs directly, no child process\n$ mybin -littleboss=start \u0026   # supervisor is created\n$ mybin2 -littleboss=reload   # child is replaced by new mybin2 process\n$ mybin -littleboss=stop      # supervisor and child are shut down\n```\n\n## Configuration\n\nSupervisor options are baked into the binary.\nThe littleboss struct type contains fields that can be set before calling\nthe Run method to configure the supervisor.\nOptions include reloading the previous binary if a reload fails,\ncontrolling how long an exiting program has to turn down its connections,\nand specifying exactly what flags control and are passed by littleboss.\n\n## An HTTP server example\n\n```go\nfunc main() {\n\tlb := littleboss.New(\"myblog\")\n\tflagHTTPS := lb.Listener(\"https\", \"tcp\", \":443\", \"address\")\n\tlb.Run(func(ctx context.Context) {\n\t\thttpMain(ctx, flagHTTPS.Listener())\n\t})\n}\n\nfunc httpMain(ctx context.Context, ln net.Listener) {\n\tsrv := \u0026http.Server{\n\t\tReadTimeout:  10 * time.Second,\n\t\tWriteTimeout: 10 * time.Second,\n\t\tIdleTimeout:  60 * time.Second,\n\t\tHandler:      blogHandler,\n\t}\n\tgo func() {\n\t\tif err := srv.ServeTLS(ln, \"certfile\", \"keyfile\"); err != nil {\n\t\t\tif err == http.ErrServerClosed {\n\t\t\t\treturn\n\t\t\t}\n\t\t\tlog.Fatal(err)\n\t\t}\n\t}()\n\n\t\u003c-ctx.Done()\n\tsrv.Shutdown(ctx)\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcrawshaw%2Flittleboss","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcrawshaw%2Flittleboss","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcrawshaw%2Flittleboss/lists"}