Shamoon
Shamoon

Reputation: 43491

Explain what script/web is in a Rails project

exec bundle exec thin -p $PORT -e ${RACK_ENV:-development} start 2>&1

That's what I have in my script/web . Can someone explain the individual pieces of that?

Upvotes: 0

Views: 51

Answers (1)

Raghu
Raghu

Reputation: 2563

This script is trying to start thin with the help of bundler. Here anything that has $ is a user argument that comes from the command line. The port and the RACK_ENV are defined from the command. The RACK_ENV has a default value of development environment which means if no environment is provided then start thing using the development environment

And as far as the 2>&1 is concerned, 1 is stdout. 2 is stderr.

Here is one way to remember this construct (altough it is not entirely accurate): at first, 2>1 may look like a good way to redirect stderr to stdout. However, it will actually be interpreted as "redirect stderr to a file named 1". & indicates that what follows is a file descriptor and not a filename. So the construct becomes: 2>&1.

Upvotes: 1

Related Questions