我目前正在尝试在 Amazon Linux Distro 上首次运行以下 Golang 构建:
https://github.com/adammck/s3-graphite
此处自述文件:
go get github.com/adammck/s3-graphite
cd $GOPATH/adammck/s3-graphite
go build
在此之后,我在 .bashrc 文件中设置我的变量,如下所示:
# AWS keys with read access to the bucket
export AWS_ACCESS_KEY_ID=xxxxxxxxxx
export AWS_SECRET_ACCESS_KEY=yyyyyyyyyy
export AWS_REGION=us-east-1
# the bucket to watch
export S3_BUCKET=my-bucket
export S3_PREFIX=dir/subdir
# the server to send metrics to
export GRAPHITE_ADDRESS=metrics.example.com
export GRAPHITE_PREFIX=s3-count.my-bucket.dir.subdir
我将我的 GOPATH 设置为以下内容:
export GOPATH="$HOME/work/"
我 cd 进入目录以运行 go build,它应该正常工作,但是当我在 go build 之后运行以下命令时:
./s3- Graphite
我收到以下错误:
INFO[0000] Starting s3-graphite...
panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xb code=0x1 addr=0x20 pc=0x4e3256]
goroutine 1 [running]:
github.com/aws/aws-sdk-go/service/s3.New(0x0, 0x0, 0x0, 0x0, 0x0, 0x3f)
/home/ec2-user/work/src/github.com/aws/aws-sdk-go/service/s3/service.go:41 +0x76
main.NewS3(0x7ffc202bef6e, 0x1b, 0x7ffc202be684, 0x9, 0x1, 0x0, 0x0)
/home/ec2-user/work/src/github.com/adammck/s3-graphite/s3.go:20 +0x66
main.main()
/home/ec2-user/work/src/github.com/adammck/s3-graphite/main.go:19 +0x21c
goroutine 2 [runnable]:
runtime.forcegchelper()
/usr/lib/golang/src/runtime/proc.go:90
runtime.goexit()
/usr/lib/golang/src/runtime/asm_amd64.s:2232 +0x1
goroutine 3 [runnable]:
runtime.bgsweep()
/usr/lib/golang/src/runtime/mgc0.go:82
runtime.goexit()
/usr/lib/golang/src/runtime/asm_amd64.s:2232 +0x1
goroutine 4 [runnable]:
runtime.runfinq()
/usr/lib/golang/src/runtime/malloc.go:712
runtime.goexit()
/usr/lib/golang/src/runtime/asm_amd64.s:2232 +0x1
这是我的 GOPATH:
$GOPATH
-bash: /home/ec2-user/work/: Is a directory
这是我执行 s3-graphite 的目录:
/home/ec2-user/work/src/github.com/adammck/s3-graphite
编辑(更新了您回答中的项目:
[ec2-user@s3-graphite]$ go version
go version go1.6.3 linux/amd64
[ec2-user@ s3-graphite]$ $GOPATH
-bash: /home/ec2-user/work: Is a directory
[ec2-user@ s3-graphite]$ pwd
/home/ec2-user/work/src/github.com/adammck/s3-graphite
[ec2-user@ s3-graphite]$ ./s3-graphite
INFO[0000] Starting s3-graphite...
panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xb code=0x1 addr=0x20 pc=0x512aa2]
goroutine 1 [running]:
panic(0x873120, 0xc82000a0e0)
/usr/local/go/src/runtime/panic.go:481 +0x3e6
github.com/aws/aws-sdk-go/service/s3.New(0x0, 0x0, 0x0, 0x0, 0x0, 0x3f)
/home/ec2-user/work/src/github.com/aws/aws-sdk-go/service/s3/service.go:41 +0x72
main.NewS3(0xc82001603a, 0x1b, 0xc82000e06a, 0x9, 0x1, 0x0, 0x0)
/home/ec2-user/work/src/github.com/adammck/s3-graphite/s3.go:20 +0x4a
main.main()
/home/ec2-user/work/src/github.com/adammck/s3-graphite/main.go:19 +0x229
[ec2-user@ s3-graphite]$
最佳答案
这里似乎发生了一些事情。要检查的一件事是,在您在那里设置环境变量后,您实际上正在采购您的 .bashrc 文件。您应该能够运行 env 命令并在当前 shell 中查看您的 AWS key 、S3 配置和 Graphite 设置。
我看到的第二个问题是您使用的库从去年开始就没有更新过。据我所知,适用于 Go 的 AWS SDK 在过去一年中发生了很大变化。应用程序输出中的“panic:”行给出了问题的提示。
panic: runtime error: invalid memory address or nil pointer dereference
似乎 nil 被传递到了它不应该传递的地方。在 panic 输出的下方,您可以看到 goroutine 1 的堆栈跟踪:
github.com/aws/aws-sdk-go/service/s3.New(0x0, 0x0, 0x0, 0x0, 0x0, 0x3f)
/home/ec2-user/work/src/github.com/aws/aws-sdk-go/service/s3/service.go:41 +0x76
main.NewS3(0x7ffc202bef6e, 0x1b, 0x7ffc202be684, 0x9, 0x1, 0x0, 0x0)
/home/ec2-user/work/src/github.com/adammck/s3-graphite/s3.go:20 +0x66
由此可以看出在s3-graphite库中s3.go文件的第20行调用了NewS3方法。然后它转到 aws-sdk-go 库并尝试创建一个新的 S3 客户端。使用以下参数:
s3.New(0x0, 0x0, 0x0, 0x0, 0x0, 0x3f)
我最好的人是你的配置没有导出到你运行可执行文件的环境,或者需要更新 s3-graphite 库以使用最新的 aws-sdk-go 版本。
关于amazon-web-services - Amazon AWS S3 的 GO 脚本运行时错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38574129/
我正在寻找执行以下操作的正确语法(在Perl、Shell或Ruby中):#variabletoaccessthedatalinesappendedasafileEND_OF_SCRIPT_MARKERrawdatastartshereanditcontinues. 最佳答案 Perl用__DATA__做这个:#!/usr/bin/perlusestrict;usewarnings;while(){print;}__DATA__Texttoprintgoeshere 关于ruby-如何将脚
从给定URL下载文件并立即将其上传到AmazonS3的更直接的方法是什么(+将有关文件的一些信息保存到数据库中,例如名称、大小等)?现在,我既不使用Paperclip,也不使用Carrierwave。谢谢 最佳答案 简单明了:require'open-uri'require's3'amazon=S3::Service.new(access_key_id:'KEY',secret_access_key:'KEY')bucket=amazon.buckets.find('image_storage')url='http://www.ex
我有一个在Linux服务器上运行的ruby脚本。它不使用rails或任何东西。它基本上是一个命令行ruby脚本,可以像这样传递参数:./ruby_script.rbarg1arg2如何将参数抽象到配置文件(例如yaml文件或其他文件)中?您能否举例说明如何做到这一点?提前谢谢你。 最佳答案 首先,您可以运行一个写入YAML配置文件的独立脚本:require"yaml"File.write("path_to_yaml_file",[arg1,arg2].to_yaml)然后,在您的应用中阅读它:require"yaml"arg
//1.验证返回状态码是否是200pm.test("Statuscodeis200",function(){pm.response.to.have.status(200);});//2.验证返回body内是否含有某个值pm.test("Bodymatchesstring",function(){pm.expect(pm.response.text()).to.include("string_you_want_to_search");});//3.验证某个返回值是否是100pm.test("Yourtestname",function(){varjsonData=pm.response.json
有没有一种简单的方法可以判断ruby脚本是否已经在运行,然后适本地处理它?例如:我有一个名为really_long_script.rb的脚本。我让它每5分钟运行一次。当它运行时,我想看看之前运行的是否还在运行,然后停止第二个脚本的执行。有什么想法吗? 最佳答案 ps是一种非常糟糕的方法,并且可能会出现竞争条件。传统的Unix/Linux方法是将PID写入文件(通常在/var/run中)并在启动时检查该文件是否存在。例如pid文件位于/var/run/myscript.pid然后你会在运行程序之前检查它是否存在。有一些技巧可以避免
我正在开发一个Ruby脚本,需要在没有Ruby解释器的情况下部署到系统上。它将需要在使用ELF格式的FreeBSD系统上运行。我知道有一个ruby2exe项目可以编译在Windows上运行的ruby脚本,但是在其他操作系统上这样做容易吗?甚至可能吗? 最佳答案 您是否检查过Rubinius或JRuby是否允许您预编译您的代码? 关于ruby-ruby脚本可以预编译成二进制文件吗?,我们在StackOverflow上找到一个类似的问题: https://
我目前正在使用带有Carrierwavegem的Rails3.2将文件上传到AmazonS3。现在我需要能够处理用户提交的大于5GB的文件,同时仍然使用Carrierwavegem。Carrierwave或Fog是否有任何其他gem或分支可以处理5GB以上的文件上传到S3?编辑:我不想重写一个完整的Rails上传解决方案,所以像这样的链接没有帮助:https://gist.github.com/908875. 最佳答案 我想出了如何做到这一点,并且现在可以正常工作了。在正确的config/environment文件中,添加以下内容以
很难说出这里要问什么。这个问题模棱两可、含糊不清、不完整、过于宽泛或夸夸其谈,无法以目前的形式得到合理的回答。如需帮助澄清此问题以便重新打开,visitthehelpcenter.关闭9年前。我需要从基于ruby的应用程序使用AmazonSimpleNotificationService,但不知道从哪里开始。您对从哪里开始有什么建议吗?
我正在使用Ruby/Mechanize编写一个“自动填写表格”应用程序。它几乎可以工作。我可以使用精彩CharlesWeb代理以查看服务器和我的Firefox浏览器之间的交换。现在我想使用Charles查看服务器和我的应用程序之间的交换。Charles在端口8888上代理。假设服务器位于https://my.host.com。.一件不起作用的事情是:@agent||=Mechanize.newdo|agent|agent.set_proxy("my.host.com",8888)end这会导致Net::HTTP::Persistent::Error:...lib/net/http/pe
我正在关注Hartl的railstutorial.org并已到达11.4.4:Imageuploadinproduction.我做了什么:注册亚马逊网络服务在AmazonIdentityandAccessManagement中,我创建了一个用户。用户创建成功。在AmazonS3中,我创建了一个新存储桶。设置新存储桶的权限:权限:本教程指示“授予上一步创建的用户读写权限”。但是,在存储桶的“权限”下,未提及新用户名。我只能在每个人、经过身份验证的用户、日志传送、我和亚马逊似乎根据我的名字+数字创建的用户名之间进行选择。我已经通过选择经过身份验证的用户并选中了上传/删除和查看权限的框(而不