Help us understand the problem. What is going on with this article?

railsでpumaが走らない時に怪しむべきtmp以下

More than 1 year has passed since last update.

現象

会社でRailsの社内ツールを作っているんですが、docker化させてadmin-pumaとadmin-nginxのDockerfileを作ってUNIXソケット接続させました。

puma.rb
bind 'unix://' + ENV.fetch("RAILS_ROOT") + "/tmp/sockets/puma.sock"

んでadmin-pumaとadmin-nginxを走らせると

$ docker-compose up admin-puma admin-nginx
.
.
.
admin-puma_1   | [1] * Listening on unix:///opt/app/tmp/sockets/puma.sock
admin-puma_1   | bundler: failed to load command: puma (/usr/local/bundle/bin/puma)
admin-puma_1   | Errno::ENOENT: No such file or directory - connect(2) for /opt/app/tmp/sockets/puma.sock

む? pumaコマンドがないとな
本当に無いのか中を見てみる

$ docker run --rm -it admin-puma sh
$ ls /usr/local/bin

いや、pumaコマンドいるな...
ググってるとどうやら同じ現象に悩んでいる人がいるようで -> https://teratail.com/questions/70599
自分でsocketsディレクトリを作れば走ると書いてあったのでtmp/socketsを作ってみると

bundler: failed to load command: puma (/usr/local/bundle/bin/puma)
Errno::ENOENT: No such file or directory @ rb_sysopen - /opt/app/tmp/pids/server.pid

server.pidが無い? こいつも同じ問題なんじゃないかと思ってtmp/pidsを作ってみると
pumaが走った...!

pumaってディレクトリ作ってくれないんですね(--;)

解決策

ということでtmp/socketstmp/pidsを作って、その中に.keepを入れて
さらに.gitignoreに下記を追加して解決しました

.gitignore
!/tmp/pid/.keep
!/tmp/sockets/.keep

走れpuma
puma

itosys
smartdrive
SmartDriveのデータプラットフォームが外部のさまざまなデータやサービスと連携し、新しい移動体験やモビリティサービスの提供など、移動の未来の到来を後押しします。
https://smartdrive.co.jp
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした