Skip to content
This repository has been archived by the owner on Dec 19, 2023. It is now read-only.

Commit

Permalink
add SetUser support
Browse files Browse the repository at this point in the history
  • Loading branch information
codeskyblue committed Sep 8, 2016
1 parent 1168486 commit 8c48c7e
Show file tree
Hide file tree
Showing 7 changed files with 124 additions and 55 deletions.
2 changes: 1 addition & 1 deletion Godeps/Godeps.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

61 changes: 35 additions & 26 deletions README.md
@@ -1,15 +1,27 @@
# gosuv
[![Build Status](https://travis-ci.org/codeskyblue/gosuv.svg)](https://travis-ci.org/codeskyblue/gosuv)

## Should not use in production now (current is in alpha)
## Should not use in production now (current is in beta)
Process management writtern by golang, inspired by python-supervisor

Features
## So why write another supervisor?
I have been using python-supervisor for many years and there are something uncomfortable feelings.

1. Log can't contains ANSI color chars
1. The configuration file can add on the web, often forgot some settings.
1. `supervisorctl reload` will cause supervisord restarted
1. Hard to set status change to fatal notifications.
1. No process performance monitor page.
1. Program starts with no common environ, eg, missing HOME and USER variable
1. Kill process default is not group kill which make sub process still running.
1. More... will added when I think of it.

## Features

* [x] Realtime log view
* [x] Web control page

* [x] Start, Stop, Tail, Reload
* [x] Start, Stop, Tail, Reload
* [x] Realtime log
* [x] Add program support
* [ ] Edit support
* [ ] Delete support
Expand Down Expand Up @@ -49,8 +61,8 @@ go-bindata-assetfs -tags bindata res/...
go build -tags bindata
```

## Usage
Start server in the background
## Quick start
After you installed gosuv, the first thing is to start server.

```sh
gosuv start-server
Expand All @@ -63,7 +75,8 @@ $ gosuv status
Server is running
```

Open web <http://localhost:11313> to see the manager page.
Open web <http://localhost:11313> to see the manager page. And follow the gif to add a program to gosuv.


![gosuv web](docs/gosuv.gif)

Expand All @@ -90,6 +103,8 @@ client:

Logs can be found in `$HOME/.gosuv/log/`

Edit config file(default located in `$HOME/.gosuv/programs.yml`) and run `gosuv reload` will take effect immediately.

## Design
HTTP is follow the RESTFul guide.

Expand All @@ -110,7 +125,7 @@ Only 4 states. [ref](http://supervisord.org/subprocess.html#process-states)

![states](docs/states.png)

## Notification (todo)
## Notification
Configuration example

```yaml
Expand All @@ -126,26 +141,20 @@ Configuration example

Now only support [pushover](https://pushover.net/api), and only status change to fatal will get notified.

# Plugin Design (todo)
Current plugins:

- [tailf](https://github.com/codeskyblue/gosuv-tailf)

All command plugin will store in `$HOME/.gosuv/cmdplugin`, gosuv will treat this plugin as a subcommand.
## Integrate with github (todo)
This is feature that will helps update your deployment environment once your updated in the github.

for example:
This part is set in the `programs.yml`, take look the example

$HOME/.gosuv/cmdplugin/ --.
|- showpid/
|- run

There is a directory `showpid`

When run `gosuv showpid`, file `run` will be called.


## Use libs
* <https://github.com/ahmetalpbalkan/govvv>
```yml
- demo-program:
command: python app.py
directory: /opt/demo
webhook:
github:
secret: 123456
command: git pull origin master
```

## LICENSE
[MIT](LICENSE)
9 changes: 8 additions & 1 deletion fsm.go
Expand Up @@ -107,6 +107,7 @@ type Program struct {
StartAuto bool `yaml:"start_auto" json:"startAuto"`
StartRetries int `yaml:"start_retries" json:"startRetries"`
StartSeconds int `yaml:"start_seconds" json:"startSeconds"`
User string `yaml:"user,omitempty" json:"user"`
Notifications struct {
Pushover struct {
ApiKey string `yaml:"api_key"`
Expand Down Expand Up @@ -165,10 +166,16 @@ type Process struct {
Status string `json:"status"`
}

// FIXME(ssx): maybe need to return error
func (p *Process) buildCommand() *kexec.KCommand {
cmd := kexec.CommandString(p.Command) // Not tested here, I think it should work
cmd := kexec.CommandString(p.Command)
// cmd := kexec.Command(p.Command[0], p.Command[1:]...)
cmd.Dir = p.Dir
if p.User != "" {
if err := cmd.SetUser(p.User); err != nil {
log.Warnf("cmd:%s chusr to %s failed", p.Name, p.User)
}
}
logDir := filepath.Join(defaultConfigDir, "log", sanitize.Name(p.Name))
if !IsDir(logDir) {
os.MkdirAll(logDir, 0755)
Expand Down
58 changes: 40 additions & 18 deletions vendor/github.com/codeskyblue/kexec/README.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 6 additions & 5 deletions vendor/github.com/codeskyblue/kexec/kexec.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 25 additions & 2 deletions vendor/github.com/codeskyblue/kexec/kexec_posix.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 9 additions & 2 deletions vendor/github.com/codeskyblue/kexec/kexec_windows.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 8c48c7e

Please sign in to comment.