doushang1890 2017-07-18 06:59
浏览 30

信号:发布后被杀死并且服务器冻结

I have this weird message after successfully posting an article.

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

The post that I make using curl is:

 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" 

The curl response is this:

> 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

The post handler is this:

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
", 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"})

}

I see that the post is created and get no errors. Nor do I get this signal: killed after any GET request, so wondering what can be wrong here and how to fix it?

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 ogg dd trandata 报错
    • ¥15 高缺失率数据如何选择填充方式
    • ¥50 potsgresql15备份问题
    • ¥15 Mac系统vs code使用phpstudy如何配置debug来调试php
    • ¥15 目前主流的音乐软件,像网易云音乐,QQ音乐他们的前端和后台部分是用的什么技术实现的?求解!
    • ¥60 pb数据库修改与连接
    • ¥15 spss统计中二分类变量和有序变量的相关性分析可以用kendall相关分析吗?
    • ¥15 拟通过pc下指令到安卓系统,如果追求响应速度,尽可能无延迟,是不是用安卓模拟器会优于实体的安卓手机?如果是,可以快多少毫秒?
    • ¥20 神经网络Sequential name=sequential, built=False
    • ¥16 Qphython 用xlrd读取excel报错