Search code examples
ruby-on-railsfayedigital-oceandokku

How to start faye server on a rails app deployed using dokku?


I've hosted my rails application on Digitalocean using Dokku. There's this need for my application to run real-time applications through Faye. I've been trying several ways like the shoreman plugin for Dokku and adding faye: bundle exec rackup faye.ru -s thin -E production to "Procfile" file. But no luck till now, need help on how I can get this Faye server running for my app.


Solution

  • You need to make several steps to have working faye server (e.g. on port 9292):

    1. Your Procfile is OK
    2. Expose port 9292 on Docker. I recommend install docker-options plugin and next dokku docker-options:add timer "-p 9292:9292"
    3. Setup your app nginx.conf. Mine is here:

      upstream app { server 127.0.0.1:49154; }
        server {
        listen      [::]:80;
        listen      80;
        server_name app.dokku.mine;
        location    / {
          proxy_pass  http://app;
          proxy_http_version 1.1;
          proxy_set_header Upgrade $http_upgrade;
          proxy_set_header Connection "upgrade";
          proxy_set_header Host $http_host;
          proxy_set_header X-Forwarded-Proto $scheme;
          proxy_set_header X-Forwarded-For $remote_addr;
          proxy_set_header X-Forwarded-Port $server_port;
          proxy_set_header X-Request-Start $msec;
      }
        location /faye {
          proxy_redirect     off;
          proxy_set_header   Upgrade    $http_upgrade;
          proxy_set_header   Connection "upgrade";
          proxy_http_version 1.1;
          proxy_buffering    off;
          proxy_cache_bypass $http_pragma $http_authorization;
          proxy_no_cache     $http_pragma $http_authorization;
          proxy_pass http://localhost:9292;
        }
      }
      

    I suggest to install nginx-alt plugin because config is overwritten on every deploy.