信号:发布后死亡和服务器冻结

时间:2017-07-18 06:59:04

标签: curl go signals go-gin

成功发布文章后,我收到了这个奇怪的消息。

[GIN] 2017/07/18 - 08:43:21 | 200 |   42.729836ms |       127.0.0.1 |  POST     /api/articles
signal: killed

我使用curl发布的帖子是:

 curl -X POST http://127.0.0.1:8080/api/articles  -v --cookie "domain=somelongstring"   -F 'title=My title' -F 'content=Some stuff comes here'  -F "file=@/home/me/Desktop/random.jpg" -H "Content-Type: multipart/form-data" 

卷曲响应如下:

> Content-Length: 84289
> Expect: 100-continue
> Content-Type: multipart/form-data; boundary=------------------------47d5c18e46bf271a
> 
< HTTP/1.1 100 Continue
< HTTP/1.1 200 OK
< Access-Control-Allow-Origin: *
< Content-Type: application/json; charset=utf-8
< Date: Tue, 18 Jul 2017 06:43:21 GMT
< Content-Length: 28
< 
* Connection #0 to host 127.0.0.1 left intact

邮政处理程序是:

func PostArticle(c *gin.Context) {
    var err error
    userId, userName := getUserId(c)
    form, err := c.MultipartForm()
    title := c.PostForm("title")
    content := c.PostForm("content")
    if err != nil {
        fmt.Printf("%+v, %+v\n", form, err)
        return
    }
    file, err := c.FormFile("file")
    if err != nil {
        log.Println(err)
        c.String(http.StatusBadRequest, fmt.Sprintf("get form err: %s", err.Error()))
        return
    }

    dir, err := os.Getwd()
    if err != nil {
        log.Fatal(err)
        return
    }

    filename := path.Join(shared.RandString(6) + path.Ext(file.Filename))

    dest := dir + "/static/photos/" + filename

    if err := c.SaveUploadedFile(file, dest); err != nil {
        c.String(http.StatusBadRequest, fmt.Sprintf("upload file err: %s", err.Error()))
        return
    }

    _, err = shared.Dbmap.Exec("INSERT INTO article (user_id, username, title, content, photo) VALUES (?, ?, ?, ?, ?)", userId, userName, title, content, filename)

    if err != nil {
        log.Fatal(err)
        return
    }
    c.JSON(http.StatusOK, gin.H{"success": "article is created"})

}

我看到帖子已创建并且没有错误。在任何GET请求之后我也不会得到signal: killed,所以想知道这里有什么问题以及如何解决它?

0 个答案:

没有答案