[ADD] worker and builder support pprof

This commit is contained in:
goodrain 2018-02-23 15:24:53 +08:00
parent acfa160aae
commit f7938d2f13
2 changed files with 19 additions and 10 deletions

View File

@ -1,19 +1,18 @@
// RAINBOND, Application Management Platform
// Copyright (C) 2014-2017 Goodrain Co., Ltd.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version. For any non-GPL usage of Rainbond,
// one or multiple Commercial Licenses authorized by Goodrain Co., Ltd.
// must be obtained first.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
@ -36,18 +35,21 @@ limitations under the License.
*/
import (
_ "net/http/pprof"
"os"
"os/signal"
"syscall"
"github.com/goodrain/rainbond/cmd/builder/option"
"github.com/goodrain/rainbond/pkg/builder/discover"
"github.com/goodrain/rainbond/pkg/builder/exector"
"github.com/goodrain/rainbond/pkg/db"
"github.com/goodrain/rainbond/pkg/db/config"
"github.com/goodrain/rainbond/pkg/event"
"os"
"os/signal"
"syscall"
"net/http"
"github.com/Sirupsen/logrus"
"net/http"
"github.com/goodrain/rainbond/pkg/builder/api"
)
@ -82,10 +84,10 @@ func Run(s *option.Builder) error {
}
defer dis.Stop()
r:=api.APIServer()
r := api.APIServer()
logrus.Info("builder api listen port 3228")
go http.ListenAndServe(":3228", r)
logrus.Info("builder begin running...")
//step finally: listen Signal
term := make(chan os.Signal)

View File

@ -33,6 +33,9 @@ import (
"github.com/goodrain/rainbond/pkg/worker/executor"
"github.com/goodrain/rainbond/pkg/worker/monitor"
"net/http"
_ "net/http/pprof"
"github.com/Sirupsen/logrus"
)
@ -94,6 +97,10 @@ func Run(s *option.Worker) error {
}
defer exporterManager.Stop()
//step 6 :enable pprof api
logrus.Info("pprof api listen port 3229")
go http.ListenAndServe(":3229", nil)
logrus.Info("worker begin running...")
//step finally: listen Signal
term := make(chan os.Signal)