Giter Site home page Giter Site logo

codeskyblue / gosuv Goto Github PK

View Code? Open in Web Editor NEW
643.0 46.0 181.0 7.77 MB

Deprecated!!! Process managerment writtern by golang, inspired by python-supervisor

License: MIT License

Go 31.24% Shell 4.40% HTML 10.61% CSS 0.33% JavaScript 53.42%
supervisor golang

gosuv's Introduction

gosuv

Build Status

中文README 不是很全,能看懂英文的还是尽量看英文

current is in beta

Process management writtern by golang, inspired by python-supervisor

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
  2. The configuration file can add on the web, often forgot some settings.
  3. supervisorctl reload will cause supervisord restarted
  4. Hard to set status change to fatal notifications.
  5. No process performance monitor page.
  6. Program starts with no common environ, eg, missing HOME and USER variable
  7. Kill process default is not group kill which make sub process still running.
  8. More... will added when I think of it.

Features

  • Web control page

  • HTTP Basic auth

  • Github webhook

  • Single log page, include search support

  • 中文文档

Requirements

Go version at least 1.6+

Installation

Binaries

The fastest way is run with. Default install location is /usr/local/bin, change env-var BINDIR will also change install location.

curl https://raw.githubusercontent.com/codeskyblue/gosuv/master/get.sh | bash

Or just download binaries

https://github.com/codeskyblue/gosuv/releases

Thanks to goreleaser which makes publish binaries automaticly.

Build from source

go get -d github.com/codeskyblue/gosuv
cd $GOPATH/src/github.com/codeskyblue/gosuv
go generate # package html resources into go
go build -tags vfs

Quick start

After you installed gosuv, the first thing is to start server.

gosuv start-server

Basic operations

$ gosuv status
PROGRAM NAME            STATUS
test                    running
test_again              stopped

$ gosuv stop test
$ gosuv start test

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

gosuv web

Configuration

Default config file stored in directory $HOME/.gosuv/, Set env-var GOSUV_HOME_DIR can change config file store directory.

  • file programs.yml contains all program settings.
  • file config.yml contains server config

File config.yml can be generated by gosuv conftest

Example config.yaml

server:
  httpauth:
    enabled: true
    username: admin
    password: admin
  addr: :8083
  name: 10.10.99.177
  master: ""
notifications:
  dingtalk:
    groups:
    - secret: c1b8032******************aa736a
      mobile:
      - "153********"
client:
  server_url: http://admin:admin@localhost:8083

master 的支持来自 https://github.com/ihaiker/distributed-gosuv 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.

Get or Update program

<GET|PUT> /api/programs/:name

Add new program

POST /api/programs

Del program

DELETE /api/programs/:name

State

Only 4 states. ref

states

Notification

Configuration example

- demo-program:
  command: ...
  notifications:
    pushover:
      api_key: [token]
      users:
      - [user1]
      - [user2]

Now only support pushover, and only status change to fatal will get notified.

Integrate with github (todo)

This is feature that will helps update your deployment environment once your updated in the github.

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

- demo-program:
  command: python app.py
  directory: /opt/demo
  webhook:
    github:
      secret: 123456
      command: git pull origin master

Alternative

LICENSE

MIT

gosuv's People

Contributors

c0b avatar codeskyblue avatar imneov avatar jijkbird avatar lunny avatar nxsre avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

gosuv's Issues

请教一下配置文件的用法

你好,我在使用的时候对这个配置文件非常困惑, 请问下 server_url 是什么意思?

server:
  httpauth:
    enabled: false
    username: uu
    password: pp
  addr: :11313
client:
  server_url: http://localhost:11313

Thank you, have a good day!

supervisor parity ?

for replacement of Supervisor/supervisor#122 it's better to have all supervisor features, or at least most useful features, especially need:

  • support of of system default config read from /etc/gosuv/config.yml if missing from user's home?
  • merge programs and config in a single configuration file?

若干使用改进反馈

gosuv比supervisor安装和配置都简单多了,但是使用过程中发现部分高级功能还不够用,希望可以加上。

  1. dashboard界面支持进程自定义分组显示,这样按组查看进程比较直观不容易操作错误。
  2. 给进程加上自定义描述,免得自己或别人忘记了这个进程干嘛用的。
  3. dashboard进程显示排序支持自定义,按名称排序或别的什么的。
  4. 一键导出配置文件,方便多机迁移。
  5. 进程stdout、stderr支持重定向到文件。
  6. 进程 stopsignal支持自定义配置SIGTERM或SIGKILL之类的。

关于remote process

supervisor是用来管理本机进程的工具,不知道gosuv是不是类似

API support /api/programs/<name>/restart ?

it's a stop call followed by start call; but better to provide /restart for convenience, also for atomicity in some scenarios

$ curl localhost:11313/api/programs/<...>/restart -X POST
404 page not found

how does this resolve dependency problems in Supervisor/supervisor#122

I found this from your comment Supervisor/supervisor#122 (comment) but I have read almost all code here, wonder how does this resolve Supervisor/supervisor#122

https://github.com/codeskyblue/gosuv/blob/master/fsm.go#L107-L130 from the state machine definition I don't see how can dependencies between programs can be defined?

type Program struct {
	Name          string   `yaml:"name" json:"name"`
	Command       string   `yaml:"command" json:"command"`
	Environ       []string `yaml:"environ" json:"environ"`
	Dir           string   `yaml:"directory" json:"directory"`
	StartAuto     bool     `yaml:"start_auto" json:"startAuto"`
	StartRetries  int      `yaml:"start_retries" json:"startRetries"`
	StartSeconds  int      `yaml:"start_seconds,omitempty" json:"startSeconds"`
	StopTimeout   int      `yaml:"stop_timeout,omitempty" json:"stopTimeout"`
	User          string   `yaml:"user,omitempty" json:"user"`
[...]

Not work button edit

VM280:3 Uncaught TypeError: scope.showEditProgram is not a function
at wi.eval (eval at Lt (vue-1.0.min.js:6), :3:15)
at HTMLButtonElement.n (vue-1.0.min.js:8)

gosuv (0.1.1)
gosuv_0.1.1_linux_amd64.tar.gz

hook update script

for go program may need to offer a script to run git pull and go build

进程启动优先级

大佬, 有些进程是有依赖其他进程的..怎么设置进程的启动优先级?

windows开机自启

大佬,windwos 开机自启是怎么搞.. 我nssm 注入到服务提示成功.但是打不开11313的web

start program with api panic

#tail -f gosuv.log 
2017/02/08 16:08:18 [INFO][github.com/codeskyblue/gosuv] fsm.go:228: [dbplus10.2.117.14:3309] use dir: /root
2017/02/08 16:08:27 [INFO][github.com/codeskyblue/gosuv] web.go:222: stop before delete program: dbplus10.2.117.14:3309
2017/02/08 16:08:27 [INFO][github.com/codeskyblue/gosuv] fsm.go:314: recv stop command
2017/02/08 16:08:27 [INFO][github.com/codeskyblue/gosuv] fsm.go:261: program(dbplus10.2.117.14:3309) quit normally
2017/02/08 16:08:30 [WARN][github.com/codeskyblue/gosuv] broadcast.go:79: broadcase write error: 1486541194877299479, GoTimeoutFunc
2017/02/08 16:08:37 [INFO][github.com/codeskyblue/gosuv] web.go:512: dbplus10.2.117.14:3309
2017/02/08 16:08:42 [INFO][github.com/codeskyblue/gosuv] fsm.go:288: start cmd(dbplus10.2.117.14:3309): ./metric -i 10.2.117.14:3309 -u maxwell -p 75JGIsP5IM9UUWxr -e 10.2.104.133:9200
2017/02/08 16:08:42 [INFO][github.com/codeskyblue/gosuv] fsm.go:228: [dbplus10.2.117.14:3309] use dir: /root
2017/02/08 16:09:15 [INFO][github.com/codeskyblue/gosuv] web.go:512: dbplus10.2.117.14:3309
2017/02/08 16:11:23 [INFO][github.com/codeskyblue/gosuv] web.go:498: read: -1 websocket: close 1001 
2017/02/08 16:13:17 http: panic serving 172.18.25.90:60055: html/template: cannot redefine "index" after it has executed
goroutine 696 [running]:
net/http.(*conn).serve.func1(0xc42035e180)
        /home/travis/.gimme/versions/go1.7.linux.amd64/src/net/http/server.go:1491 +0x12a
panic(0x7cd260, 0xc420602740)
        /home/travis/.gimme/versions/go1.7.linux.amd64/src/runtime/panic.go:458 +0x243
html/template.Must(0x0, 0xa21fa0, 0xc420602740, 0x0)
        /home/travis/.gimme/versions/go1.7.linux.amd64/src/html/template/template.go:340 +0x66
main.parseTemplate(0x841b48, 0x7, 0xc42036c000, 0x1362)
        /home/travis/gopath/src/github.com/codeskyblue/gosuv/res_bindata.go:25 +0x157
main.executeTemplate(0xa22d60, 0xc4207305b0, 0x841b48, 0x7, 0x7d4f40, 0xc4205e8c90)
        /home/travis/gopath/src/github.com/codeskyblue/gosuv/res_bindata.go:39 +0x1a3
main.(*Supervisor).renderHTML(0xc42001ccd0, 0xa27260, 0xc4207305b0, 0x841b48, 0x7, 0x7d4f40, 0xc4205e8c90)
        /home/travis/gopath/src/github.com/codeskyblue/gosuv/web.go:245 +0x13f
main.(*Supervisor).hSetting(0xc42001ccd0, 0xa27260, 0xc4207305b0, 0xc4208524b0)
        /home/travis/gopath/src/github.com/codeskyblue/gosuv/web.go:267 +0x154
main.(*Supervisor).(main.hSetting)-fm(0xa27260, 0xc4207305b0, 0xc4208524b0)
        /home/travis/gopath/src/github.com/codeskyblue/gosuv/web.go:625 +0x48
net/http.HandlerFunc.ServeHTTP(0xc42034e0b0, 0xa27260, 0xc4207305b0, 0xc4208524b0)
        /home/travis/.gimme/versions/go1.7.linux.amd64/src/net/http/server.go:1726 +0x44
github.com/codeskyblue/gosuv/vendor/github.com/gorilla/mux.(*Router).ServeHTTP(0xc4201ae460, 0xa27260, 0xc4207305b0, 0xc4208524b0)
        /home/travis/gopath/src/github.com/codeskyblue/gosuv/vendor/github.com/gorilla/mux/mux.go:100 +0x255
net/http.(*ServeMux).ServeHTTP(0xb5f2a0, 0xa27260, 0xc4207305b0, 0xc4208524b0)
        /home/travis/.gimme/versions/go1.7.linux.amd64/src/net/http/server.go:2022 +0x7f
net/http.serverHandler.ServeHTTP(0xc42008b380, 0xa27260, 0xc4207305b0, 0xc4208524b0)
        /home/travis/.gimme/versions/go1.7.linux.amd64/src/net/http/server.go:2202 +0x7d
net/http.(*conn).serve(0xc42035e180, 0xa27ba0, 0xc4203cb2c0)
        /home/travis/.gimme/versions/go1.7.linux.amd64/src/net/http/server.go:1579 +0x4b7
created by net/http.(*Server).Serve
        /home/travis/.gimme/versions/go1.7.linux.amd64/src/net/http/server.go:2293 +0x44d
2017/02/08 16:16:03 [INFO][github.com/codeskyblue/gosuv] web.go:498: read: -1 websocket: close 1001 

How to redirect child processes output to stdout?

I'm trying to use gsouv on Kubernetes. Gosuv is monitoring a service that puts log entries to stdout, but I can't find a way to make gosuv itself to redirect the output from child processes to stdout too. Is this already possible?

The web dashboard is a lifesaver BTW 👍

请教下怎么安装? 我用文档中的两种方法都安装失败了

@codeskyblue

我是在ubuntu上的安装的,用文档中的两种方法都安装失败了
root@ubuntu:/home/sysadmin# curl -k https://raw.githubusercontent.com/codeskyblue/gosuv/master/get.sh | bash
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 14 100 14 0 0 24 0 --:--:-- --:--:-- --:--:-- 25
bash: line 1: syntax error near unexpected token newline' bash: line 1:

Moved

'

root@ubuntu:/home/sysadmin# go get -d github.com/codeskyblue/gosuv

cd .; git clone https://github.com/codeskyblue/gosuv /home/sysadmin/gocode/src/github.com/codeskyblue/gosuv

Cloning into '/home/sysadmin/gocode/src/github.com/codeskyblue/gosuv'...
fatal: http://5.5.5.15:80/slogin/index.htm?vlanid=0&url=https://github.com/codeskyblue/gosuv/info/refs not valid: is this a git repository?
package github.com/codeskyblue/gosuv: exit status 128

是否有计划加入program的多进程管理?

supervisor通过numprocs指定program可以同时启动多个进程,看了下文档,大致看了下代码,没有发现对单一program启动多个进程实例的支持,是否有考虑增加这方面的支持呢?或者已有变通的方案?

server怎么变成阻塞状态的

大佬 gosuv.exe start-server 怎么让他阻塞在哪里而不是退出? 服务器上有策略- 不是阻塞的bat都会被关了..怎么破...

A new tool blueprint

$ goservice start --name some ./some-service -addr :8000
LOG: some.log
NOTIFICATIONS: DingTalk(token=xxxxxx)
$ goservice stop some
stopped
$ goservice status
NAME  STATUS
some   stopped

有没有log文件配置的地方

启动之后会把日志保存在.gosuv/log/ 目录下, 这个文件好像会越来越大,一直存在 ,不知道没有设置日志文件大小的地方

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.