Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/VividCortex/pm
Processlist manager with TCP listener
https://github.com/VividCortex/pm
Last synced: about 1 month ago
JSON representation
Processlist manager with TCP listener
- Host: GitHub
- URL: https://github.com/VividCortex/pm
- Owner: VividCortex
- License: mit
- Created: 2013-11-17T19:17:01.000Z (about 11 years ago)
- Default Branch: master
- Last Pushed: 2023-12-12T11:06:41.000Z (about 1 year ago)
- Last Synced: 2024-04-22T13:32:23.110Z (8 months ago)
- Language: Go
- Homepage:
- Size: 64.5 KB
- Stars: 81
- Watchers: 19
- Forks: 7
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-go - pm - Processlist manager with TCP listener - ★ 61 (Utilities)
- awesome-go-extra - pm - 11-17T19:17:01Z|2020-12-15T17:40:41Z| (Utilities / Fail injection)
README
# pm
![build](https://github.com/VividCortex/pm/workflows/build/badge.svg)
`pm` is a process manager with an HTTP interface. We use it at
[VividCortex](https://vividcortex.com/) to inspect and manage API server
programs. It replaces an internal-only project that was similar.`pm` is in beta and will change rapidly. Please see the issues list for what's
planned, or to suggest changes.A Processlist is useful for inspecting and managing what's running in a
program, such as an HTTP server or other server program. Processes within this
program are user-defined tasks, such as HTTP requests.## Documentation
Please read the generated package documentation for both
[server](http://godoc.org/github.com/VividCortex/pm) and
[client](http://godoc.org/github.com/VividCortex/pm/client).## Getting Started
Package pm is a process manager with an HTTP monitoring/control interface.
Processes or tasks are user-defined routines within a running Go program. Think
of the routines handling client requests in a web server, for instance. This
package is designed to keep track of them, making information available through
an HTTP interface. Client tools connecting to the later can thus monitor active
tasks, having access to the full status history with timing data. Also,
application-specific attributes may be attached to tasks (method/URI for the web
server case, for example), that will be integrated with status/timing
information.Using `pm` starts by opening a server port to handle requests for task information
through HTTP. That goes like this (although you probably want to add error
checking/handling code):```go
go pm.ListenAndServe(":8081")
```Processes to be tracked must call `Start()` with a process identifier and,
optionally, a set of attributes. Even though the id is arbitrary, it's up to the
application to choose one not in use by any other running task. A deferred call
to `Done()` with the same id should follow:```go
pm.Start(requestID, nil, map[string]interface{}{
"host": req.RemoteAddr,
"method": req.Method,
"uri": req.RequestURI,
})
defer pm.Done(requestID)
```Finally, each task can change its status as often as required with a `Status()`
call. Status strings are completely arbitrary and never inspected by the
package. Now you're all set to try something like this:```
curl http://localhost:8081/procs/
curl http://localhost:8081/procs//history
```where `` stands for an actual process id in your application. You'll get
JSON responses including, respectively, the set of processes currently running
and the full history for your chosen id.Tasks can also be cancelled from the HTTP interface. In order to do that, you
should call the DELETE method on `/procs/`. Given the lack of support in Go
to cancel a running routine, cancellation requests are implemented in this
package as panics. Please refer to the full package documentation to learn how
to properly deal with this. If you're **not** interested in this feature, you
can disable cancellation completely by running the following *before* you
`Start()` any task:```go
pm.SetOptions(ProclistOptions{
ForbidCancel: true
})
```See package `pm/client` for an HTTP client implementation you can readily use
from Go applications.## Contributing
We only accept pull requests for minor fixes or improvements. This includes:
* Small bug fixes
* Typos
* Documentation or commentsPlease open issues to discuss new features. Pull requests for new features will be rejected,
so we recommend forking the repository and making changes in your fork for your use case.## License
Copyright (c) 2013 VividCortex, licensed under the MIT license.
Please see the LICENSE file for details.## Cat Picture
![mechanic cat](http://heidicullinan.files.wordpress.com/2012/03/funny-cat-pictures-lolcats-mechanic-cat-is-on-the-job.jpg)