Rails + foreman + worker hangs server - ruby-on-rails-3

On my local machine I'm trying to start my rails app and delayed job worker using Foreman. My Procfile looks like this:
web: bundle exec rails server -p $PORT
worker: bundle exec rake jobs:work
When I start foreman only the first two web requests get executed. With the third request the server hangs. The first request is outputted in the console, the second isn't.
If I leave out the worker in my Procfile the server is running just fine and is outputting everything to the console. Also when I start the rails server and worker without Foreman everything is working fine.
So it looks like there's an issue with Foreman. I'm guessing it's a problem with Foreman not outputting anything to the console after the first request and therefore the buffer doesn't get flushed. I've searched other posts and as a result added STDOUT.sync = true to my development.rb but without any success.
Does anybody have a clue? Thanks!

UPDATE:
Tracked and resolved here:
https://github.com/ddollar/foreman/issues/244
TL;DR: Install the gem, don't use foreman.pkg
I'm facing the same problem.
Here's a link to the question I've asked on stackoverflow. #smek, if you found an answer, please reply!

I had a similar problem when trying to implement and test DJ + Foreman in my local dev environment. I intended to deploy to Heroku and was using the following article as a guide. If you are also deploying to Heroku, I recommend installing Heroku Toolbelt, which includes Foreman. In my case I already had Heroku Toolbelt installed, so I simply reinstalled it.

most of the times someone left a debugger/pry statement in the code or you put a breakpoint in somewhere.
if you can't find anything than you can use system tools like lsof or gdb to find out what your ruby process is doing at the moment. that might help finding the problem.

I just started using Foreman about an hour ago, and I was having some issues with both my rake tasks and rails server hanging when being run by Foreman. When I removed the pry gem from my Gemfile it worked, but that wasn't acceptable since I use pry in development.
Then I updated to foreman version 0.49.0 (which was released about 10 minutes ago) and the problem was fixed. Too bad I didn't start working on this task an hour later, because then I would have gotten 0.49.0 to start with and not had to mess around for an hour :)
You should try upgrading Foreman and see if it fixes your problem.

Related

Deploying React app on Ubuntu 18.04: build failed because process exited too early

I'm trying to deploy my React app on an Ubuntu 18.04 virtual machine provided by Digital Ocean. Here's my process: I have a git repo linked to the correct directory so all I need to do is a git pull followed by a 'npm run build'. Up until now, this has worked well enough and I could check the site on [my_domain]:8080, which is sufficient for now since I'm still in production.
However, when I tried to run 'npm run build' yesterday, I got this error:
I've looked it up a bit but there's so many different possibilities that it's just confusing me more. The most common issue seems to be a lack of memory on the system, but judging by the data I get when I start up the terminal, this can't be the case.
I have no clue how to proceed but I've also honestly just been starting to use DigitalOcean or Ubuntu for half a year and this is my first React app, so I would very much appreciate an explanation like I'm five ;)
Thanks so much!
The problem was apparently in the amount of RAM I had available. Solution: memory swapping. I followed this tutorial and after doing all this, the problem resolved itself.
https://www.digitalocean.com/community/tutorials/how-to-add-swap-space-on-ubuntu-18-04
You have two options to sort out the situation in your case.
1. Change the memory allocaction from node.
You can achieve this by doing so: run the command
node index.js --max-old-space-size=8000. This settings may not be persitent and you would wanna use a much more long term approach, which is of course the second option.
2. Change your swap space allocation.
Just like the article shared by #Jesse in the previous answer, you can follow that guide to change your swap space settings. it works like a charm.

Sidekiq "needs X11" in a rails project

I'm trying to use sidekiq in a project but have run into an unusual problem that makes no sense.
I've got multiple rails applications on my laptop, many of which are using sidekiq, and are running fine without any problems.
This application also uses sidekiq, and used to work however I'm not running into a problem. I've not touched the project for a while, but the only difference between now, and when it used to work is the upgrade from OS X Lion, to Mountain Lion. This however hasn't effected other projects, so I'm not sure what's going on. When I try to launch Sidekiq, I get an alert stating
To open "sidekiq," you need to install X11.
Would you like to install X11 now?
It's the standard Apple alert, however I don't understand why Sidekiq is supposedly trying to use X11, and why it isn't using it on my other projects?
I'm using
Rails 3.2.8
Ruby 1.9.3p125
Sidekiq 2.13.1
Any help would be really appreciated :)
Got it running. Turned out it wasn't an issue with Sidekiq, but rather ruby for some reason. After I updated ruby to 2.0.0 and fixed other gem issues, the app started up again and is now running. No idea what was going on but it's sorted :)

problems deploying openMRS.war to glassfish v.2

I'm trying to deploy openMRS v.1.9.2 to a local VM running CentOS & Glassfish 2 for work. Unfortunately, I could not get it to work. Normally, I just download the standalone found at source forge. I just double-click the jar, and I'm good to go.
I normally just SSH into the the VM, so I first tried doing everything through a terminal. Here are the steps I took:
Using wget, retrieve the .zip
Create a dir (I just called it /openmrs), cd into the new directory, and then expand the .zip.
cd into the directory.
At this point, there are two options to start openMRS.
Run the bash script: ./run-on-linux.sh
Run the .JAR: java -jar [insert_jar_name].jar -commandline
When I run the .JAR, I get a stack trace.
When I try to run the bash script, I get another error.
Anyways, I thought I found a potential solution in an openMRS JIRA ticket, but it seems aimed at Glassfish 3, and not Glassfish 2 (which is what I need to use).
I then tried deploying the .WAR via the Glassfish admin UI. I thought it would work, but after going through the steps of selecting a language, whether or not to use demo data, etc. I received this.
Does anyone have experience deploying openMRS to Glassfish 2.1.1? Unfortunately Glassfish 3 doesn't seem to be a realistic option. I would really appreciate any help here. Thanks.
Although it doesn't solve my problem of not being able to successfully deploy openMRS to an instance of Glassfish v.2, I did manage to get myself further by just installing MySQL on the VM. Our work machines are all set up for postgres, so I think should have guessed earlier that not having a MySQL server installation was the problem.
Here is a tutorial I used to install MySQL

Pushing new Rails 3.1 app to Heroku causing problems with Sorcery mod (requiring bson-1.4.1)

I have an app that runs great locally. Everything seems to be set up correctly to transfer over to Heroku, including the Postgres gem (and dev was done using a postgres server).
The problem is, when I try to push it up, I get error messages surrounding the three currently problematic dependencies, bson_ext, bson, and mongoid, 1.4.1. It seems that Sorcery requires these (at 1.4.1) to run. I got them installed locally by downloading the manually, but they were yanked from the online sources. So when Heroku tries to find them, it can't, and it aborts. I tried specifying to use 1.4.0 for all of them, and the app then installs fine (and does the database setup stuff for the Cedar stack, etc).
The problem is that when I load the app on their server, I get the generic "oops, there's been a problem" Heroku message. Upon checking the actual heroku log, I can't really find anything wrong. What is the way to make this work?
Thanks for your help.
I ran into the same problem, and I was able to get past it by specifying version 1.3.1 for the mongo, bson, and bson_ext gems. I just put this in my Gemfile:
gem 'mongo', '1.3.1'
gem 'bson', '1.3.1'
gem 'bson_ext', '1.3.1'

Rails assets images in production

I found some strange behavior of assets images
If I run unicorn in production mode at hosting - /assets/image.png - server give me blank image ie file exist, but size=0 . In same time at localhost I run in unicorn development mode - and all works fine, Then I run webrick at hosting - images are display fine. After that I run unicorn in production mode at localhost and images stops display, then I run unicorn in development images already doesn't work.
Rails 3.1.0.rc6, after that I update to rc8 at hosting but nothing happened
Maybe production mode build some cache, which remains forever?
There are different things that may go wrong, so here the ideas you have to check:
There is a known error in Rails 3.1, that the precompilation of assets does not work properly. See Upgrade to Rails 3.1.0 from rc6, asset precompile fails for a question with a solution.
I had problems with creating precompiled assets for production. The following worked for me (after fixing the error above):
Ensure that your application is not running in production mode.
Call bundle exec rake assets:clean. This will clean all resources hanging around.
Call bundle exec rake assets:precompile afterwards. As a result, the directory /public/assets should be filled with assets with the hash appended (e.g. icon_add-96985e087048a8c2e09405494509750d.gif instead of icon-add.gif).
Start your server in production mode.
Depending on the browser I used, I had to refresh or even clear all caches. Especially Chrome was very nasty in caching resources that he should not cache.
I hope some of the ideas will help you find the source of your problem.