Graceful restart!

This commit is contained in:
Howl
2016-04-07 19:32:48 +02:00
parent 8d99ff1070
commit ed2778e2cc
5 changed files with 107 additions and 5 deletions

22
app/v1/meta.go Normal file
View File

@@ -0,0 +1,22 @@
package v1
import (
"os"
"syscall"
"github.com/osuripple/api/common"
)
// MetaRestartGET restarts the API with Zero Downtime™.
func MetaRestartGET(md common.MethodData) (r common.Response) {
proc, err := os.FindProcess(syscall.Getpid())
if err != nil {
r.Code = 500
r.Message = "couldn't find process. what the fuck?"
return
}
r.Code = 200
r.Message = "brb"
go proc.Signal(syscall.SIGUSR2)
return
}

View File

@@ -16,6 +16,7 @@ type privilegesData struct {
PrivilegeManageRoles bool `json:"manage_roles"`
PrivilegeManageAPIKeys bool `json:"manage_api_keys"`
PrivilegeBlog bool `json:"blog"`
PrivilegeAPIMeta bool `json:"api_meta"`
}
// PrivilegesGET returns an explaination for the privileges, telling the client what they can do with this token.
@@ -34,6 +35,7 @@ func PrivilegesGET(md common.MethodData) (r common.Response) {
PrivilegeManageRoles: md.User.Privileges.HasPrivilegeManageRoles(),
PrivilegeManageAPIKeys: md.User.Privileges.HasPrivilegeManageAPIKeys(),
PrivilegeBlog: md.User.Privileges.HasPrivilegeBlog(),
PrivilegeAPIMeta: md.User.Privileges.HasPrivilegeAPIMeta(),
}
return
}