{"id":23982374,"url":"https://github.com/devel0/example-console-worker","last_synced_at":"2026-06-13T02:02:09.263Z","repository":{"id":271225908,"uuid":"912764595","full_name":"devel0/example-console-worker","owner":"devel0","description":"example console worker","archived":false,"fork":false,"pushed_at":"2025-01-18T18:27:50.000Z","size":16,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-11-18T02:27:59.474Z","etag":null,"topics":["configuration","console","csharp","hosted","logging","services","worker"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/devel0.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-01-06T10:49:48.000Z","updated_at":"2025-01-18T18:27:52.000Z","dependencies_parsed_at":"2025-01-06T12:23:09.593Z","dependency_job_id":"e9d747fd-6484-412a-babc-1a57d812f085","html_url":"https://github.com/devel0/example-console-worker","commit_stats":null,"previous_names":["devel0/example-console-worker"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/devel0/example-console-worker","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devel0%2Fexample-console-worker","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devel0%2Fexample-console-worker/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devel0%2Fexample-console-worker/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devel0%2Fexample-console-worker/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/devel0","download_url":"https://codeload.github.com/devel0/example-console-worker/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devel0%2Fexample-console-worker/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34269364,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-13T02:00:06.617Z","response_time":62,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["configuration","console","csharp","hosted","logging","services","worker"],"created_at":"2025-01-07T11:16:49.663Z","updated_at":"2026-06-13T02:02:09.258Z","avatar_url":"https://github.com/devel0.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Example console hosted worker\n\n- [features](#features)\n- [quickstart](#quickstart)\n- [dev notes](#dev-notes)\n  - [code map](#code-map)\n  - [handling ctrl+c and sigint](#handling-ctrlc-and-sigint)\n  - [further logger configurations](#further-logger-configurations)\n  - [how this project was built](#how-this-project-was-built)\n\n## features\n\n- hosted application with scoped services\n- application configuration through appsettings, environment var and user secrets\n- appsettings AppConfig object typed configuration\n- serilog logger\n- handle application graceful shutdown, allow service to invoke app shutdown through lifetime\n\n## quickstart\n\n- install repo as template\n\n```sh\ngit clone https://github.com/devel0/example-console-worker.git\ncd example-console-worker\ndotnet new install .\ncd ..\n```\n\n- create project from template\n\n```sh\ndotnet new console-worker -n project-folder --namespace My.Some\ncd project-folder\ndotnet build\n```\n\n## dev notes\n\n### code map\n\n| link | description                              |\n| ---- | ---------------------------------------- |\n| [1]  | register services                        |\n| [2]  | require scoped service from worker scope |\n| [3]  | invoke app shutdown programmatically     |\n| [4]  | inject scoped services                   |\n| [6]  | typed appconfig read from [json][5]      |\n| [7]  | sample service interface                 |\n| [8]  | sample service implmentation             |\n\n[1]: https://github.com/devel0/example-console-worker/blob/b6f63f8396352bdac1743b6a6b5032913232aec2/Extensions/SetupServices.cs#L11\n[2]: https://github.com/devel0/example-console-worker/blob/b6f63f8396352bdac1743b6a6b5032913232aec2/Implementations/Worker.cs#L25\n[3]: https://github.com/devel0/example-console-worker/blob/b6f63f8396352bdac1743b6a6b5032913232aec2/Implementations/Worker.cs\n[4]: https://github.com/devel0/example-console-worker/blob/b6f63f8396352bdac1743b6a6b5032913232aec2/Implementations/SampleService.cs\n[5]: https://github.com/devel0/example-console-worker/blob/b6f63f8396352bdac1743b6a6b5032913232aec2/appsettings.json\n[6]: https://github.com/devel0/example-console-worker/blob/b6f63f8396352bdac1743b6a6b5032913232aec2/Abstractions/AppConfig.cs\n[7]: https://github.com/devel0/example-console-worker/blob/b6f63f8396352bdac1743b6a6b5032913232aec2/Abstractions/ISampleService.cs\n[8]: https://github.com/devel0/example-console-worker/blob/b6f63f8396352bdac1743b6a6b5032913232aec2/Implementations/SampleService.cs\n\n### handling ctrl+c and sigint\n\n```sh\ndevel0@mini:~/opensource/example-console-worker$ dotnet run\n[19:24:17 DBG] doing some work with sample service\n[19:24:17 DBG] AppConfig -\u003e SampleObject -\u003e SampleVar : test var\n[19:24:17 INF] Fake await 30 sec\n^C\n[19:24:18 INF] Service received cancel during execution\n[19:24:18 DBG] sample service finished\n[19:24:18 INF] Stopping worker (fake 3 sec)...\n[19:24:21 INF] Worker gracefully stopped\n```\n\n### further logger configurations\n\nfurther console args\n\n```json\n{\n  \"Serilog\": {    \n    \"WriteTo\": [\n      {\n        \"Name\": \"Console\",\n        \"Args\": {\n          \"outputTemplate\": \"[{Level:u3}]({RequestId}) {Message:lj}{NewLine}{Exception}\",          \n          \"formatter\": \"Serilog.Formatting.Compact.CompactJsonFormatter, Serilog.Formatting.Compact\"\n        }\n      }\n    ]    \n  }\n}\n```\n\n### how this project was built\n\n```sh\ndotnet new console -n ExampleConsoleWorker\ncd ExampleConsoleWorker\ndotnet new gitignore\ndotnet add package Microsoft.Extensions.Hosting --version 9.0.0\ndotnet add package Serilog.Extensions.Hosting --version 9.0.0\ndotnet add package Serilog.Settings.Configuration --version 9.0.0\ndotnet add package Serilog.Sinks.Console --version 6.0.0\n```\n\nopen with vscode the folder then `C-S-p` and type `.NET: Generate Assets for Build and Debug` to create `.vscode` launch and build json files","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevel0%2Fexample-console-worker","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdevel0%2Fexample-console-worker","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevel0%2Fexample-console-worker/lists"}