unicorn Ruby/Rack server user+dev discussion/patches/pulls/bugs/help
 help / color / mirror / code / Atom feed
* using unicorn as a local development server
@ 2012-02-23  2:29 Patrick J. Collins
  2012-02-23  4:30 ` Eric Wong
  2012-02-24 18:47 ` Patrick J. Collins
  0 siblings, 2 replies; 9+ messages in thread
From: Patrick J. Collins @ 2012-02-23  2:29 UTC (permalink / raw)
  To: mongrel-unicorn; +Cc: Patrick J Collins

Hi Unicorn friends,

I wanted to try out Unicorn as my development server and I see that I
need to perform some configuration to make this work nicely with rails.
>From what I can tell the only real things I need to do to make unicorn
similar to the default rails server is to supply a config file with:

listen 3000
logger Logger.new(STDOUT)

...

After creating this file, I was kind of confused as to how to proceed..
Should I made a bash alias like

alias unicorn="unicorn_rails -c /path/to/unicorn_config.rb"

and lastly, is there a convention where a configuration file like this
should go on a unix/OS X system?

Thank you kindly.

Patrick J. Collins
http://collinatorstudios.com

_______________________________________________
Unicorn mailing list - mongrel-unicorn@rubyforge.org
http://rubyforge.org/mailman/listinfo/mongrel-unicorn
Do not quote signatures (like this one) or top post when replying

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: using unicorn as a local development server
  2012-02-23  2:29 using unicorn as a local development server Patrick J. Collins
@ 2012-02-23  4:30 ` Eric Wong
  2012-02-23  5:01   ` Patrick J. Collins
  2012-02-24 18:47 ` Patrick J. Collins
  1 sibling, 1 reply; 9+ messages in thread
From: Eric Wong @ 2012-02-23  4:30 UTC (permalink / raw)
  To: unicorn list; +Cc: Patrick J Collins

"Patrick J. Collins" <patrick@collinatorstudios.com> wrote:
> Hi Unicorn friends,
> 
> I wanted to try out Unicorn as my development server and I see that I
> need to perform some configuration to make this work nicely with rails.
> >From what I can tell the only real things I need to do to make unicorn
> similar to the default rails server is to supply a config file with:
> 
> listen 3000
> logger Logger.new(STDOUT)

Hi Patrick,

You shouldn't even need the logger directive, it goes to stderr by
default so your console will still show it.

> After creating this file, I was kind of confused as to how to proceed..
> Should I made a bash alias like
> 
> alias unicorn="unicorn_rails -c /path/to/unicorn_config.rb"

I generally avoid shell aliases for per-app/project things since I
split my work across different apps + terminals + machines.

If I'm (rarely) developing an app that _requires_ a persistently running
web server, I'd just run in the foreground and Ctrl-C/<uparrow+enter> to
use my shell history.

Normally I just write integration tests (sometimes starting unicorn (or
zbatery) + hitting it with curl, but often just mocking a Rack env).
Unlike most folks that develop apps that run over HTTP, I have a strong
aversion to web browsers.  I'd rather pipe curl output to "vim -" if I
have to look at any text output from the application.

You'll probably get different answers from other folks here :)

> and lastly, is there a convention where a configuration file like this
> should go on a unix/OS X system?

Nothing that I know of.  It's quite common for Rails apps to have a
config/ directory, so maybe the unicorn config file is suitable there...
_______________________________________________
Unicorn mailing list - mongrel-unicorn@rubyforge.org
http://rubyforge.org/mailman/listinfo/mongrel-unicorn
Do not quote signatures (like this one) or top post when replying

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: using unicorn as a local development server
  2012-02-23  4:30 ` Eric Wong
@ 2012-02-23  5:01   ` Patrick J. Collins
  2012-02-23  5:19     ` Eric Wong
  0 siblings, 1 reply; 9+ messages in thread
From: Patrick J. Collins @ 2012-02-23  5:01 UTC (permalink / raw)
  To: unicorn list

> You shouldn't even need the logger directive, it goes to stderr by
> default so your console will still show it.

Hmm that's odd because I noticed as soon as I began using unicorn that I got
very little output.  For example, running my app and browsing to various pages, this is all I see:

I, [2012-02-22T19:38:30.511485 #8933]  INFO -- : listening on addr=0.0.0.0:3000 fd=3
I, [2012-02-22T19:38:30.511938 #8933]  INFO -- : worker=0 spawning...
I, [2012-02-22T19:38:30.514042 #8933]  INFO -- : master process ready
I, [2012-02-22T19:38:30.515943 #8934]  INFO -- : worker=0 spawned pid=8934
I, [2012-02-22T19:38:30.516671 #8934]  INFO -- : Refreshing Gem list
DEPRECATION WARNING: Calling set_table_name is deprecated. Please use `self.table_name = 'the_name'` instead. (called from require at /Users/patrick/.rvm/gems/ruby-1.9.2-p290@global/gems/bundler-1.1.rc.7/lib/bundler/runtime.rb:68)
I, [2012-02-22T19:38:56.879509 #8934]  INFO -- : worker=0 ready
I, [2012-02-22T19:49:22.737427 #8933]  INFO -- : SIGWINCH ignored because we're not daemonized
I, [2012-02-22T19:49:35.800600 #8933]  INFO -- : SIGWINCH ignored because we're not daemonized
I, [2012-02-22T20:02:05.792427 #8933]  INFO -- : SIGWINCH ignored because we're not daemonized
I, [2012-02-22T20:03:07.315092 #8933]  INFO -- : SIGWINCH ignored because we're not daemonized
I, [2012-02-22T20:03:36.330349 #8933]  INFO -- : SIGWINCH ignored because we're not daemonized
I, [2012-02-22T20:04:33.278243 #8933]  INFO -- : SIGWINCH ignored because we're not daemonized
I, [2012-02-22T20:05:33.188828 #8933]  INFO -- : SIGWINCH ignored because we're not daemonized

...

None of the development.log output is getting piped into this, so that's why I
thought doing the Logger.new(STDOUT) would get that behavior to happen just as
it does with the default rails server.


Patrick J. Collins
http://collinatorstudios.com
_______________________________________________
Unicorn mailing list - mongrel-unicorn@rubyforge.org
http://rubyforge.org/mailman/listinfo/mongrel-unicorn
Do not quote signatures (like this one) or top post when replying

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: using unicorn as a local development server
  2012-02-23  5:01   ` Patrick J. Collins
@ 2012-02-23  5:19     ` Eric Wong
  2012-02-23  5:49       ` Alex Sharp
  0 siblings, 1 reply; 9+ messages in thread
From: Eric Wong @ 2012-02-23  5:19 UTC (permalink / raw)
  To: unicorn list

"Patrick J. Collins" <patrick@collinatorstudios.com> wrote:
> > You shouldn't even need the logger directive, it goes to stderr by
> > default so your console will still show it.
> 
> Hmm that's odd because I noticed as soon as I began using unicorn that I got
> very little output.  For example, running my app and browsing to various pages, this is all I see:

<snip>

> None of the development.log output is getting piped into this, so that's why I
> thought doing the Logger.new(STDOUT) would get that behavior to happen just as
> it does with the default rails server.

Odd, not sure what Rails is doing (I don't normally use Rails).  It must
be something weird with the way Rails modifies all existing logger
objects (I know it clobbers the default logger formatter somehow
as mentioned in the FAQ).  Oh well, I suppose your workaround is as good
as any.
_______________________________________________
Unicorn mailing list - mongrel-unicorn@rubyforge.org
http://rubyforge.org/mailman/listinfo/mongrel-unicorn
Do not quote signatures (like this one) or top post when replying

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: using unicorn as a local development server
  2012-02-23  5:19     ` Eric Wong
@ 2012-02-23  5:49       ` Alex Sharp
  0 siblings, 0 replies; 9+ messages in thread
From: Alex Sharp @ 2012-02-23  5:49 UTC (permalink / raw)
  To: unicorn list

> "Patrick J. Collins" <patrick@collinatorstudios.com (mailto:patrick@collinatorstudios.com)> wrote:
> > Hmm that's odd because I noticed as soon as I began using unicorn that I got
> > very little output. For example, running my app and browsing to various pages, this is all I see:
> 

Rails logs to a file by default, so you probably need to set the Rails logger somewhere in your config:

Rails.logger = ::Logger.new($stdout)

--
Alex Sharp
Zaarly, Inc | @ajsharp | github.com/ajsharp | alexjsharp.com



_______________________________________________
Unicorn mailing list - mongrel-unicorn@rubyforge.org
http://rubyforge.org/mailman/listinfo/mongrel-unicorn
Do not quote signatures (like this one) or top post when replying

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: using unicorn as a local development server
@ 2012-02-24 17:43 Matt Smith
  2012-02-24 23:10 ` Eric Wong
  0 siblings, 1 reply; 9+ messages in thread
From: Matt Smith @ 2012-02-24 17:43 UTC (permalink / raw)
  To: mongrel-unicorn

> Normally I just write integration tests (sometimes starting unicorn (or
> zbatery) + hitting it with curl, but often just mocking a Rack env).
> Unlike most folks that develop apps that run over HTTP, I have a strong
> aversion to web browsers. I'd rather pipe curl output to "vim -" if I
> have to look at any text output from the application.


This is slightly off topic, so I will make this concise, or this can
be taken offline.

What you are talking about, Eric, is exactly the workflow I am working
toward. I am almost there, but still too dependent on the browser. So
2 questions:
1) Would you share what you use for integrations tests for rails and
rack apps in general? (rack test, minitest, capybara, etc.)
2) Are there any resources you would point to going into further detail?

Feel free to respond here or directly, as this is a tangent.

Thanks, Matt
_______________________________________________
Unicorn mailing list - mongrel-unicorn@rubyforge.org
http://rubyforge.org/mailman/listinfo/mongrel-unicorn
Do not quote signatures (like this one) or top post when replying

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: using unicorn as a local development server
  2012-02-23  2:29 using unicorn as a local development server Patrick J. Collins
  2012-02-23  4:30 ` Eric Wong
@ 2012-02-24 18:47 ` Patrick J. Collins
  2012-02-24 19:26   ` Alex Sharp
  1 sibling, 1 reply; 9+ messages in thread
From: Patrick J. Collins @ 2012-02-24 18:47 UTC (permalink / raw)
  To: mongrel-unicorn

Hi,

No one else really replied on this---  But I am wondering if anyone can
tell me how I can get my rails development log to stream (as in tail -f)
into the unicorn server output...   I thought I needed to do logger =
Logger.new(STDOUT) in my config file, but that doesn't seem to do it.

Any ideas?

Patrick J. Collins
http://collinatorstudios.com


On Wed, 22 Feb 2012, Patrick J. Collins wrote:

> Hi Unicorn friends,
> 
> I wanted to try out Unicorn as my development server and I see that I
> need to perform some configuration to make this work nicely with rails.
> From what I can tell the only real things I need to do to make unicorn
> similar to the default rails server is to supply a config file with:
> 
> listen 3000
> logger Logger.new(STDOUT)
> 
> ...
> 
> After creating this file, I was kind of confused as to how to proceed..
> Should I made a bash alias like
> 
> alias unicorn="unicorn_rails -c /path/to/unicorn_config.rb"
> 
> and lastly, is there a convention where a configuration file like this
> should go on a unix/OS X system?
> 
> Thank you kindly.
> 
> Patrick J. Collins
> http://collinatorstudios.com
> 
> 
_______________________________________________
Unicorn mailing list - mongrel-unicorn@rubyforge.org
http://rubyforge.org/mailman/listinfo/mongrel-unicorn
Do not quote signatures (like this one) or top post when replying

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: using unicorn as a local development server
  2012-02-24 18:47 ` Patrick J. Collins
@ 2012-02-24 19:26   ` Alex Sharp
  0 siblings, 0 replies; 9+ messages in thread
From: Alex Sharp @ 2012-02-24 19:26 UTC (permalink / raw)
  To: unicorn list; +Cc: Patrick J. Collins

Hey Patrick, 

Sorry, I replied a few days ago but looks like I missed your email on the CC. This should solve it:

> "Patrick J. Collins" <patrick@collinatorstudios.com (mailto:patrick@collinatorstudios.com)> wrote:
> > Hmm that's odd because I noticed as soon as I began using unicorn that I got
> > very little output. For example, running my app and browsing to various pages, this is all I see:
> 

Rails logs to a file by default, so you probably need to set the Rails logger somewhere in your config:

Rails.logger = ::Logger.new($stdout)

--
Alex Sharp
Zaarly, Inc | @ajsharp | github.com/ajsharp (http://github.com/ajsharp) | alexjsharp.com (http://alexjsharp.com)




_______________________________________________
Unicorn mailing list - mongrel-unicorn@rubyforge.org
http://rubyforge.org/mailman/listinfo/mongrel-unicorn
Do not quote signatures (like this one) or top post when replying

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: using unicorn as a local development server
  2012-02-24 17:43 Matt Smith
@ 2012-02-24 23:10 ` Eric Wong
  0 siblings, 0 replies; 9+ messages in thread
From: Eric Wong @ 2012-02-24 23:10 UTC (permalink / raw)
  To: unicorn list

Matt Smith <matt@nearapogee.com> wrote:
> Eric Wong wrote:
> > Normally I just write integration tests (sometimes starting unicorn (or
> > zbatery) + hitting it with curl, but often just mocking a Rack env).
> > Unlike most folks that develop apps that run over HTTP, I have a strong
> > aversion to web browsers. I'd rather pipe curl output to "vim -" if I
> > have to look at any text output from the application.
> 
> This is slightly off topic, so I will make this concise, or this can
> be taken offline.
> 
> What you are talking about, Eric, is exactly the workflow I am working
> toward. I am almost there, but still too dependent on the browser. So
> 2 questions:
> 1) Would you share what you use for integrations tests for rails and
> rack apps in general? (rack test, minitest, capybara, etc.)

For Rack apps, I normally use test/unit (minitest in 1.9) + Rack::Mock*.
test/test_watcher.rb in raindrops[1] is a public example of that.

I don't develop a lot of Rack apps, though.  I haven't touched Rails in
ages, but last time I used test/unit and some builtin Rails test
extensions.

If I'm testing within Ruby, I stay with test/unit because it's
bundled/maintained with the latest version(s) of Ruby.  Back in the day,
I know some projects had trouble migrating to Ruby 1.9.1 because rspec
wasn't 1.9-compatible at the time (it is now).


Back to Unicorn (and Rainbows!)
-------------------------------

For testing HTTP servers (or anything that interacts with
non-Ruby-components), I'll use scripts in other languages
(shell/Perl/awk) and external tools (e.g. curl) to shake out potential
bugs.

I worry about "self-cancelling" bugs which can be hidden from tests
because I didn't understand something (often Ruby itself) well enough.
Ruby 1.9 encodings is/was especially confusing to me, so I reached
outside of Ruby in many cases.


[1] - git clone git://bogomips.org/raindrops

[2] - For the few Rack apps I write, almost all of them are APIs or
      targeted at lynx or curl users.  I hate pretty things :)
_______________________________________________
Unicorn mailing list - mongrel-unicorn@rubyforge.org
http://rubyforge.org/mailman/listinfo/mongrel-unicorn
Do not quote signatures (like this one) or top post when replying

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2012-02-24 23:10 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-02-23  2:29 using unicorn as a local development server Patrick J. Collins
2012-02-23  4:30 ` Eric Wong
2012-02-23  5:01   ` Patrick J. Collins
2012-02-23  5:19     ` Eric Wong
2012-02-23  5:49       ` Alex Sharp
2012-02-24 18:47 ` Patrick J. Collins
2012-02-24 19:26   ` Alex Sharp
  -- strict thread matches above, loose matches on Subject: below --
2012-02-24 17:43 Matt Smith
2012-02-24 23:10 ` Eric Wong

Code repositories for project(s) associated with this public inbox

	https://yhbt.net/unicorn.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).