dongshuan8722 2017-03-10 18:10
浏览 215
已采纳

如何登录Amazon Web Service(AWS)?

I have a project built in Golang and deployed on a Docker instance in AWS.

Internally I create a log file where the program write several logs.

How can I access that log file?

Is there another correct way to logging?

Thanks

  • 写回答

4条回答 默认 最新

  • duanlu4371 2017-03-14 02:22
    关注

    Thanks for reply.

    After a while looking for the solution to the problem, I found it!

    Firstly, I needed to mount the file that is inside the instance in the docker-host.

    To do this I add a Json file in the root folder of my project called Dockerrun.aws.json ( http://docs.aws.amazon.com/es_es/elasticbeanstalk/latest/dg/create_deploy_docker_image.html#create_deploy_docker_image_dockerrun )

    That is the file that declares the shared folder (volumes) (beetwen docker-host and instance) where I save my log file . This line is equivalent to adding -v flag in the docker run command (https://docs.docker.com/engine/tutorials/dockervolumes/#mount-a-host-directory-as-data-volume). I do this this way because I can not add mount to a running instance and i cant stop it by ssh.

    {
      "AWSEBDockerrunVersion": "1",
      "Volumes": [
      {
        "HostDirectory": "/var/log/",
        "ContainerDirectory": "/go/src/app/log"
      }
      ]
    }
    

    Then to tell aws that I want to download my log file when I request records. (Tail (last 100 lines), bundle or rotate) I add these files to the .ebextension folder in my project directory. ( http://docs.aws.amazon.com/en_us/elasticbeanstalk/latest/dg/using-features.logging.html#health-logs-extend )

    Log_bundle.conf

    Files:
    "/opt/elasticbeanstalk/tasks/bundlelogs.d/log_bundle.conf":
        Mode: "000755"
        Owner: root
        Group: root
        Content: |
          /var/log/application.log
    

    Log_rotate.config

    Files:
    "/opt/elasticbeanstalk/tasks/bundlelogs.d/log_rotate.conf":
        Mode: "000755"
        Owner: root
        Group: root
        Content: |
          /var/log/application.log
    

    Log_tail.config

    Files:
    "/opt/elasticbeanstalk/tasks/publishlogs.d/log_tail.conf":
        Mode: "000755"
        Owner: root
        Group: root
        Content: |
          /var/log/application.log
    

    Finally, I dont try Amazon Could Watch but is the next step.

    Regards

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?

悬赏问题

  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 关于大棚监测的pcb板设计
  • ¥15 stm32开发clion时遇到的编译问题
  • ¥15 lna设计 源简并电感型共源放大器
  • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)
  • ¥15 Vue3地图和异步函数使用