{"id":16161424,"url":"https://github.com/gamemann/go-spawn-and-output-logs-from-process","last_synced_at":"2025-03-18T22:30:44.101Z","repository":{"id":164143962,"uuid":"639273658","full_name":"gamemann/Go-Spawn-And-Output-Logs-From-Process","owner":"gamemann","description":"This repository shows how to spawn processes within a Go program and output their stdout and stderr pipes to a log file!","archived":false,"fork":false,"pushed_at":"2023-05-11T20:10:18.000Z","size":2,"stargazers_count":11,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-28T12:30:02.327Z","etag":null,"topics":["go","go-lang","golang","logs","output","processes","spawn","stderr","stdout"],"latest_commit_sha":null,"homepage":"","language":"Go","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/gamemann.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}},"created_at":"2023-05-11T06:11:42.000Z","updated_at":"2025-02-16T12:55:53.000Z","dependencies_parsed_at":"2023-06-02T03:00:14.031Z","dependency_job_id":null,"html_url":"https://github.com/gamemann/Go-Spawn-And-Output-Logs-From-Process","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/gamemann%2FGo-Spawn-And-Output-Logs-From-Process","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gamemann%2FGo-Spawn-And-Output-Logs-From-Process/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gamemann%2FGo-Spawn-And-Output-Logs-From-Process/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gamemann%2FGo-Spawn-And-Output-Logs-From-Process/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gamemann","download_url":"https://codeload.github.com/gamemann/Go-Spawn-And-Output-Logs-From-Process/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243950813,"owners_count":20373664,"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":["go","go-lang","golang","logs","output","processes","spawn","stderr","stdout"],"created_at":"2024-10-10T02:25:13.373Z","updated_at":"2025-03-18T22:30:43.841Z","avatar_url":"https://github.com/gamemann.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Go Spawn \u0026 Output Logs From Process\nThis is a small project to demonstrate how to spawn multiple processes from a Go program and have the Go program write their `stdout` and `stderr` lines to a log file.\n\nIn this example, we have `test` and `loader` Go programs.\n\nThe `test` program outputs a random string from the `messages` variable each second to `stdout`. This is just used as a demo program.\n\nThe `loader` program runs the `test` program five times and outputs their `stdout` and `stderr` pipes to a log file in the `logs/` directory (e.g. `logs/\u003cpid\u003e.log`).\n\n## Motives\nI'm working on a private project which spawns processes from a Go program. However, I wanted to write the `stdout` and `stderr` pipes from these spawned processes to a file so I knew what was going on. Since the project utilized Docker which extended build/test time, I decided to write a separate open source program to achieve this goal since I could easily test things.\n\n## Building\nYou may use `make` via Makefile to build everything easily. Otherwise, you may use `go build loader.go` and `go build test.go` to build the Go programs.\n\n## Running\nSimply run the `loader` executable to test.\n\n```bash\n./loader\n```\n\n**Note** - The `remove_logs.sh` file is ran on each loader start. This Bash script simply removes all log files in the `logs/` directory so we start off from a clean slate and the loader ignores any errors from executing the file.\n\n## Credits\n* [Christian Deacon](https://github.com/gamemann)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgamemann%2Fgo-spawn-and-output-logs-from-process","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgamemann%2Fgo-spawn-and-output-logs-from-process","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgamemann%2Fgo-spawn-and-output-logs-from-process/lists"}