From a8121d05f8f3db8cdb7b9381baa535404afe96b1 Mon Sep 17 00:00:00 2001 From: Liang Ding Date: Thu, 16 May 2019 09:51:58 +0800 Subject: [PATCH] =?UTF-8?q?:whale:=20#296=20=E5=8E=BB=E6=8E=89=E5=91=BD?= =?UTF-8?q?=E5=90=8D=E7=A9=BA=E9=97=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Dockerfile | 13 ------------- conf/wide.go | 12 +++--------- main.go | 4 +--- output/namespace.go | 25 ------------------------- output/namespace_linux.go | 32 -------------------------------- output/run.go | 5 ----- playground/run.go | 5 ----- session/sessions.go | 2 +- 8 files changed, 5 insertions(+), 93 deletions(-) delete mode 100644 Dockerfile delete mode 100644 output/namespace.go delete mode 100644 output/namespace_linux.go diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index 217bb46..0000000 --- a/Dockerfile +++ /dev/null @@ -1,13 +0,0 @@ -FROM golang:latest -MAINTAINER Liang Ding - -ADD . /go/src/github.com/b3log/wide -ADD vendor/ /go/src/ -RUN go install github.com/visualfc/gotools github.com/nsf/gocode github.com/bradfitz/goimports - -RUN useradd wide && useradd runner - -WORKDIR /go/src/github.com/b3log/wide -RUN go build -v - -EXPOSE 7070 diff --git a/conf/wide.go b/conf/wide.go index d6fff24..afdb0e1 100644 --- a/conf/wide.go +++ b/conf/wide.go @@ -83,16 +83,13 @@ var Wide *conf // configurations of users. var Users []*User -// Indicates whether runs via Docker. -var Docker bool - // Load loads the Wide configurations from wide.json and users' configurations from users/{username}.json. func Load(confPath, confIP, confPort, confServer, confLogLevel, confStaticServer, confContext, confChannel, - confPlayground string, confDocker bool, confUsersWorkspaces string) { + confPlayground string, confUsersWorkspaces string) { // XXX: ugly args list.... initWide(confPath, confIP, confPort, confServer, confLogLevel, confStaticServer, confContext, confChannel, - confPlayground, confDocker, confUsersWorkspaces) + confPlayground, confUsersWorkspaces) initUsers() } @@ -156,7 +153,7 @@ func initUsers() { } func initWide(confPath, confIP, confPort, confServer, confLogLevel, confStaticServer, confContext, confChannel, - confPlayground string, confDocker bool, confUsersWorkspaces string) { + confPlayground string, confUsersWorkspaces string) { bytes, err := ioutil.ReadFile(confPath) if nil != err { logger.Error(err) @@ -237,9 +234,6 @@ func initWide(confPath, confIP, confPort, confServer, confLogLevel, confStaticSe Wide.Port = confPort } - // Docker flag - Docker = confDocker - // Server Wide.Server = strings.Replace(Wide.Server, "{IP}", Wide.IP, 1) Wide.Server = strings.Replace(Wide.Server, "{Port}", Wide.Port, 1) diff --git a/main.go b/main.go index 0cb0562..4a4b6fd 100644 --- a/main.go +++ b/main.go @@ -57,7 +57,6 @@ func init() { confContext := flag.String("context", "", "this will overwrite Wide.Context if specified") confChannel := flag.String("channel", "", "this will overwrite Wide.Channel if specified") confStat := flag.Bool("stat", false, "whether report statistics periodically") - confDocker := flag.Bool("docker", false, "whether run in a docker container") confPlayground := flag.String("playground", "", "this will overwrite Wide.Playground if specified") confUsersWorkspaces := flag.String("users_workspaces", "", "this will overwrite Wide.UsersWorkspaces if specified") @@ -75,8 +74,7 @@ func init() { i18n.Load() event.Load() - conf.Load(*confPath, *confIP, *confPort, *confServer, *confLogLevel, *confStaticServer, *confContext, *confChannel, - *confPlayground, *confDocker, *confUsersWorkspaces) + conf.Load(*confPath, *confIP, *confPort, *confServer, *confLogLevel, *confStaticServer, *confContext, *confChannel, *confPlayground, *confUsersWorkspaces) conf.FixedTimeCheckEnv() session.FixedTimeSave() diff --git a/output/namespace.go b/output/namespace.go deleted file mode 100644 index 5760b93..0000000 --- a/output/namespace.go +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (c) 2014-2019, b3log.org & hacpai.com -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// +build !linux - -package output - -import ( - "os/exec" -) - -func SetNamespace(cmd *exec.Cmd) { - // do nothing -} diff --git a/output/namespace_linux.go b/output/namespace_linux.go deleted file mode 100644 index b4266eb..0000000 --- a/output/namespace_linux.go +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright (c) 2014-2019, b3log.org & hacpai.com -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package output - -import ( - "os/exec" - "syscall" -) - -func SetNamespace(cmd *exec.Cmd) { - cmd.SysProcAttr = &syscall.SysProcAttr{} - // cmd.SysProcAttr.Cloneflags = syscall.CLONE_NEWUSER /*| syscall.CLONE_NEWNS*/ | syscall.CLONE_NEWUTS | syscall.CLONE_NEWPID | syscall.CLONE_NEWIPC /*| syscall.CLONE_NEWNET*/ - cmd.SysProcAttr.Credential = &syscall.Credential{ - Uid: 1001, - Gid: 1001, - } - - // cmd.SysProcAttr.UidMappings = []syscall.SysProcIDMap{{ContainerID: 0, HostID: 1001, Size: 1}} - // cmd.SysProcAttr.GidMappings = []syscall.SysProcIDMap{{ContainerID: 0, HostID: 1001, Size: 1}} -} diff --git a/output/run.go b/output/run.go index 4ab53f2..52610d6 100644 --- a/output/run.go +++ b/output/run.go @@ -24,7 +24,6 @@ import ( "strings" "time" - "github.com/b3log/wide/conf" "github.com/b3log/wide/session" "github.com/b3log/wide/util" ) @@ -64,10 +63,6 @@ func RunHandler(w http.ResponseWriter, r *http.Request) { cmd := exec.Command(filePath) cmd.Dir = curDir - if conf.Docker { - SetNamespace(cmd) - } - stdout, err := cmd.StdoutPipe() if nil != err { logger.Error(err) diff --git a/playground/run.go b/playground/run.go index 579f7a8..031fbe6 100644 --- a/playground/run.go +++ b/playground/run.go @@ -22,7 +22,6 @@ import ( "os/exec" "time" - "github.com/b3log/wide/conf" "github.com/b3log/wide/output" "github.com/b3log/wide/session" "github.com/b3log/wide/util" @@ -61,10 +60,6 @@ func RunHandler(w http.ResponseWriter, r *http.Request) { cmd := exec.Command(filePath) - if conf.Docker { - output.SetNamespace(cmd) - } - stdout, err := cmd.StdoutPipe() if nil != err { logger.Error(err) diff --git a/session/sessions.go b/session/sessions.go index a501787..268bee0 100644 --- a/session/sessions.go +++ b/session/sessions.go @@ -39,7 +39,7 @@ import ( "github.com/b3log/wide/event" "github.com/b3log/wide/log" "github.com/b3log/wide/util" - "github.com/go-fsnotify/fsnotify" + "github.com/fsnotify/fsnotify" "github.com/gorilla/sessions" "github.com/gorilla/websocket" )