I have a fairly large Rails app that is getting increasingly harder to develop on. The development environment has gotten slower and slower and WeBrick is taking forever to start up.
The oddest thing however, is that whenever I change code in the logic (controllers or models), the server crashes with an 'Illegal Instruction' so I have to restart the server every time I change something. This doesn't happen when I change the views.
The code works just fine every time I restart as well as in our production environment.
I'm fairly new to web development, only been doing it for a year. It's very possible I'm making some sort of mistake that is causing an overflow or something faulty in the binary that the cpu can't handle it. Could that be the case even though the code seems to work just fine and have the correct expected outcome?
Also, could someone direct me towards finding ways to speed up my development environment. It's starting to get ridiculous. It's only for this particular repository.
It's a Rails 3.0.4 app using Ruby 1.9.2-p136 with MYSQL db. Using the rails engine 'spree' which is the majority of the code base. WEBrick is the development server.
The first thing I would do is to abandon WEBrick since its performances very poor. You'll find a lot of articles online on why it is so and almost all of them advice not to use it in a production environment, especially if your app is large enough. I could suggest thin + nginx, since I use them and have really nothing to complain about, but a final choice could depend on so many parameters, that I strongly suggest you to first document yourself on the different possibilities out there (and there are a lot!).
With regard to the illegal instruction issue, please notice that you're using a quite "bleeding edge" mix of RoR end Ruby with WEBrick that is not known for its stability! Choosing for a more conservative solution (e.g. Ruby 1.8.7?) and dismissing WEBrick should really solve this problem.
Related
I'm taking on the challenge of trying to test and develop with ERPNext. I'm new to ERPNext, Docker, Compose, Git, etc. I'm going to need to learn these from scratch.
What is the general most efficient way to install ERPNext (for testing purposes for now) on either a Mac or Windows computer?
Below are my criteria:
I need to be able to create backups and transfer them and implement
them to a different computer if necessary.
I'm also attempting to do this in as budget-friendly way as
possible. I'm probably not going to be spending money on hosting or
anything of the sort (completely free is the goal).
ERPNext needs to be easily upgradeable/downgradeable to different versions
The implementation of ERPNext will eventually need custom code/integrations
I've read that there are different methods of using ERPNext, depending on the OS, including VirtualBox, and Windows Subsystem for Linux. I'm looking for the fastest, least resource-hungry, and most versatile solution
I will check out the official ERPNext documentation, but I would also like to know other people's personal experiences and methods.
This is a big task to take on, so I'm looking for some advice before delving into this.
You can use frappe_docker setup to quickly get the environment up and running.
https://github.com/frappe/frappe_docker
If you want least resource hungry option, you can setup a site using bench.
https://github.com/frappe/bench
I am looking for a simple, no frills, docker-compose based solution so I can start playing with some common tools, without having to devote lots of time into learning to configure the infrastructure. It should pull from the official images of the included projects, to make things super standardized and easy to move forward.
Ideally, I can have local directories mounted, so I can just edit my code directly, and have it served up through the container. Even better is to have the database stored similarly, in case I wind up liking it and want to port it into a project.
Edit:
Since it seems nobody gets it. The reasons for wanting this are:
No local installation of tools to pollute my development environment.
No rebuilding of containers as I change my code, learn, and test out features.
Not using any exotic features or special configuration, so official containers from the distributions should be sufficient.
Clean roadmap to scaling up to a real project. Acts as a template going forward.
Not spending time on tasks that are not relevant to the final goal (configuring a platform that may never be used).
It seems clear to me that a significant portion of development should use containerized runtimes for building/testing, without installing things on the real host. That would avoid a lot of hassles and conflicts, and allows easy revisiting of old development environments.
This seems like an obvious thing that should be readily available, just like the standard images that many projects provide.
As I am just looking to evaluate things, I'm not that picky about tools. A development language/framework (Node.js), a database (MySQL), and web server capability (anything). If it's PostgreSQL, MongoDB, whatever. I just don't want to spend days wrestling with setting things up, before I actually get to start evaluating the platform.
I tried asking this over on DevOps a few days ago. All I got was one snarky and unhelpful comment, which has since been deleted.
I have tried following a bunch of different tutorials around the web and answers given here, but they all fail, and I really don't want to get sidetracked debugging them.
It seems like this would be a common template for starting many projects, regardless of complexity or expertise. So, I'm really surprised I can't find it. It also seems like a good way to lure in new users, which should incentivize project maintainers to have these.
I am experimenting JRuby on Rails and need some guidance/tips in choosing the server. I have used nginx (and passenger) for my RoR in the past. JRuby wiki page Servers provide a lot of options and I have no experience in any of them.
What I am looking for is a simple to install, easy to scale server or the one widely used (so that I can find solutions if I am stuck)
I do realize this might be a broad question and the answer would be "it depends..." but would appreciate some pointers.
I might be biased being on the Trinidad team, but I still think it's top ... esp. as it handles high concurrency well while still being much lighter than TorqueBox (which I would also recommend if you do want something beyond just a web server e.g. built-in jobs but be aware that some of it is TB/JRuby specific). Most other options mentioned are Java web servers, which you can rule out if you do not want to install a Java server, warbling your application and deploying it as a .war file.
p.s. for the (next) version 1.5.0 re-deploys are to be revisited and one should be able to do some (memory leak-free) zero-down time deployments.
I have an existing website written in ASP.net, I have recently switched to Mac full time (With Windows in Boot Camp), and need to write a public API for accessing my website's MySQL data. I primarily want to use the API to allow building an iOS application.
I am interested in learning either Ruby on Rails or Node.js, I haven't used either of them yet.
Which language would be better for me to learn?
Rails is a relatively mature web framework based in Ruby and is designed for handling object-mapped data persistence in a relational database backend.
Node.js is much newer on the scene, and unlike Rails, is a more bare-bones package that allows for server-side Javascript applications thanks to a pretty tight HTTP(S) API. Node applications are by nature event-driven, which may or may not be ideal for your application.
Since it seems that you'll need data-persistence (you mentioned accessing MySQL data...), Rails might be easier to get started with, as it comes packaged with all the things you need in this respect and is designed to facilitate this sort of application.
If you you don't really need relational data persistence, Node is probably a better bet as it stays out of your way and lets you decide how to handle things. It's important to note that Node is a much more bare-bones "framework" than Rails -- if you want something slightly higher-level but still lighter than Rails that runs on Node, express is good place to start.
Still, if you want to try Node (I will confess: it's a lot of fun!), it's totally possible to access MySQL in a nice, event-driven (non-blocking) way. Here are two modules that will be helpful:
node-dbslayer
node-mysql
Neither is a language; they're frameworks. There is no "better", there may be a "more suitable" (probably not in this case).
Which would you prefer to develop in, Ruby (Rails), or JavaScript (node.js)?
Would you like to transfer that knowledge to a different job without rampup time (Rails)?
Would you like to learn something a bit more esoteric, event-driven (node.js)? (Ruby has Event Machine, but IMO node.js takes it a bit further.)
So this new application is just a middle man between your ASP.NET thing and your other clients.
In that case, totally use node. Node is great at being networking glue. Node scales great with IO bound applications (i.e. being a network middleman).
If you're going to use node then you probably want to look at express to make it easier.
I'm using JRuby 1.5.6 on Rails to build myself an application that will periodically go away and retrieve any RSS podcasts that I have subscribed too.
I've chosen JRuby primarily because I'm familiar with Java, wish to utilise the Rails framework and most importantly I'm able to perform the "heavy lifting" tasks in Java when Ruby falls short of my requirements. Up to now (and I'm still in the early stages of development) this hybrid approach has been working extremely well.
I'm now at a point where I'm needed to implement scheduling of periodic and long running tasks to a background process. My requirements are to have a database backed scheduling system that is, ideally, well documented, currently maintained and clean.
My problem now is that after many days of researching suitable off the self gem packaged solutions, I appear to be left with very few options because of my use of JRuby.
Some of the gems I've tried...
rufus scheduler
Having used this before I'm happy with it's interface and documentation, however there is a lack of database persistence, hence a deal breaker for my requirements.
delayed_job
My ideal solution would be delayed_job. Good documentation, still being maintained and database backed, however, breaks under JRuby due to ObjectSpace being turn off (we can however fix this by re-enabling) but more fatally the dependence on the daemons gem which throws a "fork is unsafe and disabled by default on JRuby" error due to limitations within the JRuby implementation.
There is a fork on github that doesn't have a dependence on daemons, however I'm not happy switching to a fork off the main development branch and I'm still left with the ObjectSpace issue which I'm unsure as to it's performance impact.
quartz-jruby
While there have been various quartz based gems before, this very recent offering is another attempt at providing a slick ruby-like interface. There is however minimal documentation and I'm unsure as to if this can be database backed, my gut feeling is that it is not.
The problem
While I've only highlighted 3 options here, I'm aware that there are others available. I've however not been able to find a solution to tick all 3 requirement boxes (docs, maintained, database backed).
So the questions are...
Has anyone else been in this situation and come up with a solution?
Has anyone managed to get delayed_job working in whatever form?
Are there any better solutions out there that I've overlooked and will satisfy my needs?
We have been using delayed_job (collectiveidea/v1.8.4) under JRuby in production for over an year now.
We have not enabled ObjectSpace and also we do not use daemons gem.
Created a simple rake task
namespace :product do
desc "Start Delayed Job Worker"
task :dw => :environment do
Delayed::Worker.new.start
end
end
and daemonize it in the OS dependent way. On linux,
nohup jruby -S rake product:dw > $log_dir/delayed_job_console.log 2>&1 &
I would recommend resque as the queueing system. Resque is similar to DelayedJob, but in my opinion much better. It was developed at GitHub and is used as their queueing system. I've also been using it in production for almost a year and I've been very happy with it.
Resque definitely has JRuby support, and all you have to do to get scheduled jobs is have a simple scheduler. Some recommend resque-scheduler, though I like to keep it simple and use clockwork which has a nice DSL for writing simple cron-like tasks to queue up schedulers (see: clockwork README). With that, you can just schedule things like so:
every(1.hour, 'tasks.alert') { Resque.push(:cron, :class => 'TaskAlert', :args => []) }
Check https://github.com/kares/jruby-rack-worker
This allows delayed_job solution under jruby environment.
Still work in progress.
At the time of writing, my experience is that it works fine with a single worker.
Though I have difficulties at making additional workers run.
I originally asked this question in Dec '10 and have since developed a solution that I thought would be worth posting back for others to reference.
As others have pointed out, it is possible to get libraries like delayed_job working with JRuby and for some this might be an acceptable solution. I however didn't want a solution that required an additional process running and with that in mind I have developed a gem that utilises Java's Executor framework and integrates it with ActiveRecord.
The result is acts_as_executor which allows a Rails 3.x application to interact with executors and tasks (which will run in a proper Java thread) just as it would any other ActiveRecord model.
I've recently moved the gem to release candidate 1. Take a look at GitHub and Rubygems.
N.B. RubyGems default page still shows beta2 for some reason. rc1 is still the latest release however.