Graceful restart!
This commit is contained in:
22
app/v1/meta.go
Normal file
22
app/v1/meta.go
Normal 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
|
||||
}
|
@@ -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
|
||||
}
|
||||
|
Reference in New Issue
Block a user