Bundler won't find puma when deploying Rails 5 app - ruby-on-rails

Just FYI, this is the first time I'm deploying something on a production server. I went through this guide as my server is also hosted on DO.
The environment is pretty much the same - I'm using Ubuntu 14.04, Ruby 2.3.3 (rbenv) and rails 5.
I followed everything step by step and I have gotten no error, however, now I'm getting a 502 bad gateway when accessing my public IP.
I have noticed that for some reason after starting puma manager (sudo start puma-manager), the directory "shared/sockets/puma.sock" is not getting created.
When I start puma manually by using -> RACK_ENV=production bundle exec puma -C config/puma.rb from my app directory, I get the following error:
bundler: failed to load command: puma (/root/.rbenv/versions/2.3.3/bin/puma)
Errno::ENOENT: No such file or directory - connect(2) for /root/belooga/shared/sockets/puma.sock
Any idea of what I might be doing wrong? Should you need to see any file, please let me know and I'll provide anything that might be needed.
Cheers!
EDIT:
I have double-checked all the paths in:
myapp/config/puma.rb
/etc/puma.conf
/etc/nginx/sites-available/default

... the directory "shared/sockets/puma.sock" is not getting created.
Here is your problem, create the directory before you start the puma server.

Related

How to configure Solr standalone in Production server with Rails application using sunspot gem?

I'm looking to deploy solr-8 in production as standalone mode with Ruby on Rails application. While running bundle exec rake sunspot:solr:reindex getting this error
RSolr::Error::Http - 500 Internal Server Error
Any help would be appreciated!
using gem sunspot in development and is working fine with standalone solr-8 on local machine.
Solr is running in cloud mode. Please share the configuration which is used to talk to solr and rails for index
It's really straight forward setup but took long time for me to resolve.
In standalone mode it is bit tricky to communicate with rails
we need to copy schema.xml and solrconfig.xml to server/solr/your-core/conf/
as Solr-8 have some deprecation warning. Please carefully read warnings.
Once you copied files restart solr and run
rake sunspot:solr:reindex

foreman start doesn't seem to bind puma socket in development

I'm working a Rails application ran into some problems with a 502 error when I tried to go to our staging site. This thread had the answer I needed by adding to puma.rb:
application_path = '/home/deploy/hotel-automata/shared'
bind "unix://#{application_path}/sockets/puma.socket"
I was also able to start the server in development by running foreman start -p 3000. The question I have is how does this not throw an error? The application_path I have definitely doesn't exist in my local computer and running bundle exec puma or bundle exec rails server threw an error on file not found. Is this something that's specific to foreman or am I missing something? I looked around for a while but couldn't find anything related to this.
Also, is this the best way to do this? I feel that using an exact path might not be the best way here but I'm not sure what else I should do. Any suggestions on this point would be much appreciated too.
Also, here's my Procfile:
web: bundle exec rails server
redis: redis-server
sidekiq: bundle exec sidekiq

AppEngine Flexible Ruby environment, application startup error: /usr/bin/env: 'ruby2.5': No such file or directory

I'm trying to deploy an API-only Rails 5 application to AppEngine Flex w/ the standard Ruby runtime, and I'm getting the following error at the very end:
Updating service [default] (this may take several minutes)...failed.
ERROR: (gcloud.app.deploy) Error Response: [9]
Application startup error:
/usr/bin/env: 'ruby2.5': No such file or directory
I'm specifying ruby '2.5.1' in my Gemfile and I've added an explicit .ruby-version file to the root of my project set to 2.5.1 as well.
I have no other debugging information available to me in the logs, no other fancieness. My entrypoint command is:
bundle exec rails server Puma -p $PORT
I can provide more details if needed, not sure what else might be relevant. Any pointers? As far as I can tell, nothing on my side is asking for a version of ruby that specifically at execution time.
Thanks!
EDIT: Here's my app.yaml file
entrypoint: bundle exec rails server Puma -p $PORT
env: flex
runtime: ruby
UPDATE:
I can verify that I'm having similar problems when trying to exec rake tasks like db:migrate:
--------- EXECUTE COMMAND ----------
bundle exec rake db:migrate
/usr/bin/env: 'ruby2.5': No such file or directory
ERROR
ERROR: build step 0 "gcr.io/google-appengine/exec-wrapper:latest" failed: exit status 127
--------------------------------------------------------------------------------------------------------------------------------------------------------
OK I now see what has happened after debugging the docker image locally. Because I was on ubuntu and had used system ruby to install gems it had embedded /usr/bin/env ruby2.5 into every executable script that was bundled into my app. I deleted all gems and switched to rbenv for managing Ruby version which mitigated this odd behavior between unbuntu's ruby and my app.

Vue with Rails (webpacker) Error: "Cannot GET /"

I made new project with Rails and Vue using webpacker. Firstly I got strange error
Cannot read property 'compile' of undefined
So I hit yarn upgrade webpack-dev-server --latest which was the correct answer and helped me but then when I hit: ./bin/webpack-dev-server my webpack dev server starts and all looks fine but at http://localhost:3035/ I am getting the "Cannot GET /" message.
JS console: Failed to load resource: the server responded with a status of 404
I also tried to reinstall webpacker...
When running your Rails application locally you'll need to start both the rails server and the webpack-dev-server. I typically use foreman with a simple Procfile, although you can also start both of these by hand.
# Procfile
server: bin/rails server
assets: bin/webpack-dev-server
Then you can run the Procfile and startup both servers with: foreman start
The webpack-dev-server port (3035) is not the port you'll be connecting to for seeing your application. Start up both servers and go to localhost:3000 and you'll see your rails application root path page (or default rails page if you dont have routes yet).
One thing to note, if you're using Foreman to start your servers it will default your rails port to 5000 instead of 3000. You can configure this either in the Procfile or when you call foreman if you want different behavior.

The localhost page isn’t working ruby rails puma osx

I have been working on a rails app for months and then, all of a sudden the pumas server does not work on my laptop. I've tried different older branches (in case I changed something) I've uninstalled and reinstalled ruby. Nope. It DOES work if I do a fresh pull and load it on my desktop, so it seems to be something on my laptop? I am really lost.
Here's what I've done already:
Restarted the computer
reinstalled ruby
Tried puma
Tried rails s
Tried different branches to see if something I did yesterday somehow broke it
reinstalled gems
The error is:
The localhost page isn’t working
localhost didn’t send any data.
However, right before it was running this error, it ran a Request time out error, if that matters.
What I really don't understand is why it's only happening on one computer.
I am running Ruby 2.3.0 and rails 4.2.6
UPDATE
It DOES running rails server and not puma.
The problem is, I'm using foreman to start sidekiq with my server, and that's how I debug sidekiq queues. Strangely, sidekiq still works, but I can't access the localhost page.
This is my procfile:
web: bundle exec puma -C config/puma.rb
worker: bundle exec sidekiq -c 2 -q default -q mailers
Again, I haven't changed anything with puma and rails s works fine.

Resources