|
Sil posted:Any resources on figuring out what app/web server to use? Is that a big deal? Assuming you're using some sort of configuration management like Puppet or Chef it presumably doesn't make a lot of difference. Passenger is considered more "old school" but I've no up to date reference on whether it's actually falling behind.
|
# ? May 9, 2014 11:29 |
|
|
# ? May 15, 2024 04:56 |
|
Arachnamus posted:Is that a big deal? Assuming you're using some sort of configuration management like Puppet or Chef it presumably doesn't make a lot of difference. That's what I'm wondering: Does it make a difference? From what I can find Unicorn is pretty much fine for MRI Rails apps and as fast/handles as many requests per second as any of the other options. I guess the only question is about performance with multiple apps running on one instance. I'll just go with Nginx/Unicorn/pg for now and worry about it later.
|
# ? May 9, 2014 11:52 |
|
It can be a big deal, especially in environment with limited RAM. The process-per-request model used in many MRI installations use is pretty memory-hungry (processes are a lot fatter than threads) than what you get with the traditional thread-per-request model, so you can often serve more concurrent requests with the threaded model, especially if using JRuby (no GIL limiting parallelism). The somewhat COW-friendly GC found in MRI 2.0+ helps a bit, but it's still not perfect. I'd benchmark your app with 3 different setups: a) MRI / Unicorn with multiple processes b) MRI / Puma with multiple threads c) JRuby / torqbox with multiple threads Before benchmarking, remember to warm up the JVM (10-20k requests should be fine) if using JRuby, to increase your db pool size to match the number of web threads and to set config.threadsafe! to true if on rails 3.
|
# ? May 9, 2014 13:06 |
|
Sil posted:Wait. Where did I pick up that """ """ thing? It must have been some rails tutorial book, but I could have sworn they said that's the way to do multiline strings in ruby. I see now, in IRB, that regular string literals do that just fine. Have you been reading any python tutorials? It uses triple quotes for multiline strings.
|
# ? May 9, 2014 13:15 |
|
Sil posted:Any resources on figuring out what app/web server to use? Depends on what your apps need to do. Unicorn is great for small distributions, easy to set up and run, but it has issues when getting hammered because it can only handle as many requests as there are worker processes. Puma is an evented server, so if you need to do things like run websockets or other neat things, you should consider that. I also like that the ability to run as a service is built in. Puma doesn't work as well with MRI because MRI has a blocking mutex that doesn't allow Puma to do its full multi-threaded thing. I'm not the biggest fan of passenger's way of doing things. It's built to work with apache and running it on its own to work with nginx is less than ideal. My current projects are using Puma + rubinius for websocket support. I don't have any benchmarks for you, though. Also, Digital Ocean is cheaper and faster than AWS Micro.
|
# ? May 9, 2014 18:10 |
|
kayakyakr posted:Depends on what your apps need to do. Unicorn is great for small distributions, easy to set up and run, but it has issues when getting hammered because it can only handle as many requests as there are worker processes. My account is still eligible for AWS free tier offerings so that's why I'm playing with those while I learn vagrant/chef. Is RDS worth using Amazon for when I want a dedicated DB server? I'm guessing it's equivalently easy to hookup a DO droplet or an EC2 instance to an RDS instance. There's just so much stuff on AWS. My current plan is Digital Ocean for the app RDS/same DO instance for the DB and S3 for storage space.
|
# ? May 10, 2014 08:46 |
|
Sil posted:My account is still eligible for AWS free tier offerings so that's why I'm playing with those while I learn vagrant/chef. TL;DR if you're just learning and have free credit go for the smallest RDS with no failover and try it out.
|
# ? May 10, 2014 15:46 |
|
Sil posted:Any resources on figuring out what app/web server to use? Micro instances are poop from a butt. The biggest issue is that you don't have any guaranteed CPU, so if you have a lovely neighbor, you're gonna have a bad time. For multiple apps, you're going to have RAM problems too I bet.
|
# ? May 11, 2014 03:20 |
|
I'm using url_for on an object that has an :as clause in it's route. The proper helper is "myscope_mymodel_path" code:
|
# ? May 12, 2014 17:55 |
|
tldr: Do you use Vagrant/Chef? Any tips? Next step in the never-ending saga of me being poo poo at ops: I'm trying to use Vagrant and Chef together. Chef to plan out my deploys as well as to provision development VMs, through Vagrant, that match the target environment. Basically, my ultimate goal, is a DB box running Postgres and a Web box running rails with unicorn and nginx, hooked up together. Unfortunately every loving tutorial on setting up a Rails machine with Vagrant and Chef seems to break at one point or another unless I use the tutorials locked cookbook, vagrant, chef versions. Berkshelf was apparently bundler for cookbooks and worked great with Vagrant up until October and then it wasn't. Somehow Vagrant minor releases broke the integration between them. Now I'm supposed to use kitchen whatever. Ok, but can I use kitchen whatever to provision a development box? No? Ish? All I want, initially, is to run Rails, Postgres, Nginx all on one precise32 VM, but it seems that I lack the reading comprehension to turn 50 different github readme's and blog posts into a deploy/provision system. I could just do this poo poo with a script.sh file and say 'gently caress portability!', but I'm convinced that I must be screwing the pooch in an easily fixable way. In fairness I did get it running once today(using librarian-chef as a terrible package manager), but then when I tried to apply the Vagrantfile/Cheffile combo to a fresh box it failed. Fml. I'm guessing the tools are way overkill for my needs, but getting to easily load up a development environment that matches production(mostly) is very appealing. I was probably being naive thinking I could get going with it in a couple of days.
|
# ? May 12, 2014 18:02 |
|
Sil posted:on one precise32 VM Why would you use a 32 bit os in 2014? You can't stream postgres wal from 32bit to 64bit, so you'd be stuck with a dump/restore if you ever needed to get bigger.
|
# ? May 12, 2014 18:04 |
|
Pardot posted:Why would you use a 32 bit os in 2014? You can't stream postgres wal from 32bit to 64bit, so you'd be stuck with a dump/restore if you ever needed to get bigger. Because I'm just trying to make a(17) tutorial(s) work. I tried the files with the precise64 box and they still don't work. Wiped the gemset and giving it a fresh try, maybe Vagrant was dicking my by choosing an older Chef version. e. heeeey! The idiot was me! Which is great since that means my Chef/Vagrant setup works! I'd just mixed up the Vagrantfile syntax between some tutorials which was screwing up everything. Sil fucked around with this message at 19:09 on May 12, 2014 |
# ? May 12, 2014 18:14 |
|
KoRMaK posted:I'm using url_for on an object that has an :as clause in it's route. The proper helper is "myscope_mymodel_path" I haven't seen your system or requirements so take this as a maybe, but you might be trying to be too clever with your code.
|
# ? May 13, 2014 13:33 |
|
I wrote a module and a helper to figure this out. the Module goes on the object and enables it to respond to a method that returns it's nested route prefix. The helper figures out if it should turn that into a [:prefix, @item] array or if just @item will suffice.
|
# ? May 13, 2014 15:26 |
|
Was asking about this in the web development thread, but it might be better placed here. I'm new to web programming, though I've done years of C++ stuff on my own. I've written a dozen or so console based RPG generators and rollers that I'd like to make available on a website. I was told there was a simple way to do that, with the kind of IO I used in the exe's, and I was suggested to try Ruby and Sinatra. I installed them both, tried out the Hello Worlds for both, and they worked fine. So I moved onto the actual problem. Pokeyman gave me this starter code: code:
Just to test that it wasn't the addition of the .txt fileout, I commented it all out and recompiled the C++ exe, though it still has the same problem. It just hangs. I use the standard cin and cout of C++. This is compiled and run on windows7. Not sure how to fix that little bit of code to run the console stuff in a browser! Any ideas?
|
# ? May 19, 2014 01:48 |
|
This isn't necessarily a rails question but I have a rails app on Heroku with the free tier postgres database. I have a table that is going to be populated by several RSS feeds - I consume the feeds once a day and add new URLs to this table. The url field is a string(255) and I have it indexed for uniqueness. Here's my question: My application code does this check before inserting new items: code:
|
# ? May 19, 2014 21:55 |
|
A unique index is fine. It stores it in a b+ tree so it's O(ln(n)) to determine if it's unique. The index will also be used as a regular index for selects and whatnot. You can just try to insert and rescue duplicate violation exceptions, rather than check first. In fact, the check first really doesn't do anything because someone could have added a violating record in between the check and the insert. Which is why the rails unique validator is huge bullshit that doesn't do anything.
|
# ? May 19, 2014 22:04 |
|
Pardot posted:In fact, the check first really doesn't do anything because someone could have added a violating record in between the check and the insert. Which is why the rails unique validator is huge bullshit that doesn't do anything. Don't you see, uniqueness checks are "business logic" and don't belong in the database.
|
# ? May 19, 2014 22:06 |
|
Thanks guys. The check is in the application code (instead of just rescuing failed inserts) because prior to inserting a record I am parsing the Open Graph metadata from the URL and storing it as well, and I don't want to do that over and over again because it is slow. I have more appropriate checks on uniqueness elsewhere, this is mostly to prevent parsing OG metadata for URLs the application has already seen.
|
# ? May 19, 2014 22:12 |
|
Sailor_Spoon posted:Don't you see, uniqueness checks are "business logic" and don't belong in the database. I'm so angry about that, the loving using timestamp instead of timestamptz everywhere, and the general lowest common denominator (mysql) avoidance of powerful postgres features. The latter is getting a little better with support for hstore and json out of the box, and I did get word that maybe a patch to make timestamptz default would be accepted but and I don't use rails myself anymore much.
|
# ? May 19, 2014 22:13 |
|
Since I'm in here I may as well ask, does anyone have a preferred method/gem for fixing mixed content warnings? The app is SSL but some of the Open Graph images I'm displaying are http:// and so I'm getting mixed content warnings. I'm pretty close to writing my own image proxy because everything I can find looks too complicated but if there's another way that would be great!
|
# ? May 19, 2014 22:33 |
|
Sub Par posted:Since I'm in here I may as well ask, does anyone have a preferred method/gem for fixing mixed content warnings? The app is SSL but some of the Open Graph images I'm displaying are [url]http://[/url] and so I'm getting mixed content warnings. I'm pretty close to writing my own image proxy because everything I can find looks too complicated but if there's another way that would be great! But doesn't Open Graph supports TLS just fine?
|
# ? May 19, 2014 22:38 |
|
Smol posted:But doesn't Open Graph supports TLS just fine? I may be too dumb to know what this means. I am fetching the open graph metadata from various webpages and displaying the image specified by og:image in the application. Most of the time, this is an image like http://my-insecure-server.com/someimage.jpg and I need a way to prevent the browser from identifying this as "mixed content", so proxying it through my server like Facebook does or through some other means.
|
# ? May 19, 2014 22:51 |
|
Sub Par posted:This isn't necessarily a rails question but I have a rails app on Heroku with the free tier postgres database. I have a table that is going to be populated by several RSS feeds - I consume the feeds once a day and add new URLs to this table. The url field is a string(255) and I have it indexed for uniqueness. Here's my question: if you want to do this in ruby: Ruby code:
Ruby code:
Sub Par posted:I may be too dumb to know what this means. I am fetching the open graph metadata from various webpages and displaying the image specified by og:image in the application. Most of the time, this is an image like http://my-insecure-server.com/someimage.jpg and I need a way to prevent the browser from identifying this as "mixed content", so proxying it through my server like Facebook does or through some other means. If you can, instead of doing http://, just do //. That will allow the browser to choose whether it wants to use TLS or just regular old http.
|
# ? May 20, 2014 00:43 |
|
Thanks a bunch, that seems to have resolved things.
|
# ? May 20, 2014 09:59 |
|
Ravendas posted:
Does your exe ever actually exit? The web server will hang until the `read` completes.
|
# ? May 20, 2014 15:01 |
|
Wouldn't be surprised if it was just a bug in ruby. IO-related stuff doesn't work properly half of the time on Windows (and even if it does, it probably has different semantics), because nobody tests MRI on Windows.
|
# ? May 20, 2014 15:53 |
|
So I've started playing with Rails, following a MOOC from UNM on Web Application Architectures. A question that pops up, and that is seldom answered in intro stuff is - What if i regret and just want to get rid of it all ? or I want to rehearse, start fresh and do it all over. In other words - will deleting the root and child folders and files you've created in a project be enough to clean the system from all traces, or is there some uninstall routine one should follow ? Sorry if this is a stupid question, but those need to be asked too.
|
# ? May 20, 2014 16:13 |
|
sofokles posted:So I've started playing with Rails, following a MOOC from UNM on Web Application Architectures. It's an interpreted language, so all of what you've done resides in the project directory. Deleting the project directory deletes the application. Unless, of course, you're working with ruby and created a few executables that were placed in your bin directories. Not a common thing to do, though.
|
# ? May 20, 2014 16:18 |
|
Thanks mate
|
# ? May 20, 2014 16:31 |
|
If you're using a "real" database (not SQLite), you'd also want to drop the DB to remove all traces.
|
# ? May 20, 2014 19:58 |
|
How do I determine the max length of a text column in Mysql via rails? I know its 65,535b but I want to figure that out dynamically incase we expand/contract that column size.
|
# ? May 21, 2014 18:03 |
|
If nothing else (I'm not a MySQL expert), you can parse the output of SELECT COLUMN_TYPE FROM information_schema.COLUMNS WHERE TABLE_NAME = 'foos' AND COLUMN_NAME = 'whatever' and look for mediumtext, longtext or whatnot. There's also Foo.columns['whatever'].type, but I'm not sure if it differentiates between all the possible text/blob column types in mysql. Smol fucked around with this message at 21:50 on May 21, 2014 |
# ? May 21, 2014 21:37 |
|
Another dumb question from me! I have Post model (in a Rails 3 app) that has just a couple attributes: user_id, title, content. I have the model set up to protect against mass assignment so people can't post as other userscode:
code:
|
# ? May 22, 2014 16:49 |
Um, you can make user_id accessible and just go by current user? Then write a custom method for your system thing
|
|
# ? May 22, 2014 16:57 |
|
Edit: ok I did this which seems to do what I want and keep things secure. In the model:code:
code:
Sub Par fucked around with this message at 17:41 on May 22, 2014 |
# ? May 22, 2014 17:13 |
|
Sub Par posted:Another dumb question from me! I have Post model (in a Rails 3 app) that has just a couple attributes: user_id, title, content. I have the model set up to protect against mass assignment so people can't post as other users p = Post.new(:title => some_object.title, :content => some_object.title) p.user_id = 10 p.save Does that work?
|
# ? May 22, 2014 17:55 |
|
Could you make a Post.system scope that implies a user_id of 10?
|
# ? May 22, 2014 21:51 |
|
Depending on how big this app is it might be a good idea to just upgrade to Rails 4 and use strong_params for this. It's what it was built for pretty much.
|
# ? May 22, 2014 21:59 |
|
|
# ? May 15, 2024 04:56 |
|
prom candy posted:Depending on how big this app is it might be a good idea to just upgrade to Rails 4 and use strong_params for this. It's what it was built for pretty much. Yeah that's what I wanted to do. It's not a huge app but it's something I was working on months ago while trying to learn rails, and I've just recently come back to it and I don't feel like going through all that. At this stage I have about 50 users and it's proof-of-concept level complete. Once I make it feature-complete I will probably upgrade to rails 4. Thanks for the suggestions everyone. I'm going to try out a few different approaches and see which I like best and then just move on. Since I know this can be done more easily in rails 4 I may just ditch this feature for now and come back to it after the upgrade.
|
# ? May 22, 2014 22:22 |