{"id":42276314,"url":"https://github.com/ilya1st/goservicetools","last_synced_at":"2026-01-27T07:51:48.405Z","repository":{"id":57611910,"uuid":"109371213","full_name":"ilya1st/goservicetools","owner":"ilya1st","description":"Framework to make service from your application(with different log types, http, suid, graceful restart)","archived":false,"fork":false,"pushed_at":"2018-09-19T20:08:44.000Z","size":54,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-06-20T13:40:25.583Z","etag":null,"topics":["framework","go","golang","graceful-restart-process","graceful-shutdown","lockfile","logging","pidfile","service","signals","suid"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ilya1st.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":"2017-11-03T08:29:06.000Z","updated_at":"2024-06-20T13:40:25.584Z","dependencies_parsed_at":"2022-08-27T09:50:38.187Z","dependency_job_id":null,"html_url":"https://github.com/ilya1st/goservicetools","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/ilya1st/goservicetools","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ilya1st%2Fgoservicetools","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ilya1st%2Fgoservicetools/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ilya1st%2Fgoservicetools/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ilya1st%2Fgoservicetools/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ilya1st","download_url":"https://codeload.github.com/ilya1st/goservicetools/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ilya1st%2Fgoservicetools/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28809319,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-27T07:41:26.337Z","status":"ssl_error","status_checked_at":"2026-01-27T07:41:08.776Z","response_time":168,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["framework","go","golang","graceful-restart-process","graceful-shutdown","lockfile","logging","pidfile","service","signals","suid"],"created_at":"2026-01-27T07:51:47.660Z","updated_at":"2026-01-27T07:51:48.401Z","avatar_url":"https://github.com/ilya1st.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# goservicetools - library to write services on go\n\n[![Build Status](https://travis-ci.org/ilya1st/goservicetools.svg?branch=master)](https://travis-ci.org/ilya1st/goservicetools)[![Go Report Card](https://goreportcard.com/badge/github.com/ilya1st/goservicetools)](https://goreportcard.com/report/github.com/ilya1st/goservicetools)\n\nFramework to make service from your application(with different log types, http, suid, graceful restart)\n\n## Overview\n\nThis package was written for case you need write own unix service in golang.\nFor example. I want my application to have following things:\n\n 1. Application must have own configuration file and tools to read them. And must work at least in 3 environments defined by ENV variable or command line option(prod, dev, test)\n 1. Application must be able write own log files and support at least 2 formats(plain and json) an 4 outputs(stderr, file, syslog, and no output) with syslog like facilities.\n 1. Application must be able work as daemon:\n    1. Support SIGINT, SIGTERM\n    1. Support work with logrotate and reopen logs on SIGHUP signal.\n    1. Application must be able open HTTP and HTTPS service and give user configure them\n    1. Application must have support for setuid(+self restart) to support open lower ports without using docker or capabilities\n    1. Application must support graceful self restart on SIGUSR1 signal with no reopening ports(it must transmit port listener descriptors to new instance)\n    1. Things like logfile, pidfile\n\n## Quickstart\n\nTo setup your application you must define child struct from IAppStartSetup interface or from DefaultAppStartSetup. On code documentation to IAppStartSetup it's described call order of methods.\n\nSo this is your first program code.\n\n```go\npackage main\n\nimport (\n    \"fmt\"\n    \"os\"\n\n    \"github.com/ilya1st/goservicetools\"\n)\n\n// CustomAppStart app start there\n// Look at goservicetools.DefaultAppStartSetup\n// understand on how to write applications\ntype CustomAppStart struct {\n    goservicetools.DefaultAppStartSetup\n}\n\nfunc main() {\n    fmt.Println(\"Just open https://localhost:8000 when ready\")\n    exitCode, err := goservicetools.AppStart(\u0026CustomAppStart{})\n    if err != nil {\n        fmt.Fprintf(os.Stderr, \"Error occurred while starting app\\n%v\\n\", err)\n        os.Exit(exitCode)\n    }\n    goservicetools.AppRun()\n}\n```\n\nLibrary contains additional API to work with loggers, configuration files, command line arguments.\nThere is examples directory you can see on how to work with library components\n\n## External libraries used\n\n* github.com/rs/zerolog for logging\n* github.com/ilya1st/rotatewriter to support log rotate on SIGHUP\n* github.com/ilya1st/configuration-go to support HJSON(json with not strict syntax) to work with configuration files\n* github.com/theckman/go-flock for lock file\n\n## Application configuration file\n\nWe use HJSON format. Configuration file contains 3 main sections:\n\n* prod - for production environments\n* dev - for development\n* test - for test environment(e.g. run unit tests)\n\nEach section contains own options.\n\nYou can see in conf/config.hjson documented configuration file with different options.\nYou can add own options there, e.g. number of ports user want to listen. See helloservice example on how to work with configuration.\n\n## Graceful port reopening\n\nSee AppStop() internals to understand on how does that works and helloservice example where gracefully  restarted does not need open socket to listen - it gives file descriptor from previous instance.\n\n### Limitations for graceful restart\n\nFor correct application restart when setuid enabled in configuration and used lower ports - you may not to change ports numbers in configuration file between restarts","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Filya1st%2Fgoservicetools","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Filya1st%2Fgoservicetools","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Filya1st%2Fgoservicetools/lists"}