简体   繁体   English

我如何使用yas3fs做一份新手工作?

[英]How can I make a working upstart job with yas3fs?

I've got a very simple upstart config for maintaining a yas3fs mount. 我有一个非常简单的新贵配置,用于维护yas3fs挂载。

start on filesystem
stop on runlevel [!2345]

respawn
kill timeout 15
oom never
expect fork

script
    . /etc/s3.env
    export AWS_ACCESS_KEY_ID
    export AWS_SECRET_ACCESS_KEY
    exec /opt/yas3fs/yas3fs.py /mnt/something --url=s3://something --cache-path=/mnt/s3fs-cache --mp-size=5120 --mp-num=8
end script'

What happens is that I get two copies of yas3fs.py running. 发生的是,我得到了yas3fs.py的两个副本。 One appears to mount the s3 bucket correctly, but the other is CONSTANTLY respawned by upstart (presumably because it errors due to the other one running). 一个似乎正确安装了s3存储桶,但另一个却被新贵重新生成(大概是因为它由于另一个运行而出错)。

If I throw in an "expect fork", the job never starts correctly. 如果我扔了“期望叉”,则该作业将无法正确启动。 I just want to be able to have this simple mount safely able to be restarted, stopped, etc as an upstart job. 我只是希望能够安全地将这个简单的挂载作为新贵的工作重新启动,停止等。 Ideas? 想法?

I'm not an upstart expert, but this script should work: 我不是新贵专家,但是此脚本应该可以运行:

start on (filesystem and net-device-up IFACE=eth0)
stop on runlevel [!2345]

env S3URL="s3://BUCKET[/PREFIX]"
env MOUNTPOINT="/SOME/PATH"

respawn
kill timeout 15
oom never

script
    MOUNTED=$(mount|grep " $MOUNTPOINT "|wc -l)
    if [ $MOUNTED = "1" ]; then
        umount "$MOUNTPOINT"
    fi
    exec /opt/yas3fs/yas3fs.py "$MOUNTPOINT" --url="$S3URL" --mp-size=5120 --mp-num=8 -f
end script

pre-stop script
    umount "$MOUNTPOINT"
end script

The trick is to leave yas3fs in foreground with the '-f' option, it seems there are too many forks to manage otherwise. 诀窍是使用“ -f”选项将yas3fs保留在前台,否则似乎有太多的派生需要管理。

I added a check to clean (ie unmount) the mount point if yas3fs dies in some wrong way (eg "kill -9"). 如果yas3fs以某种错误的方式死亡(例如“ kill -9”),我添加了一个检查以清理(即卸载)安装点。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM