Erlang Mailing Lists

Author Message

<  Erlyweb mailing list  ~  Many questions

dmitriid
Posted: Mon Feb 11, 2008 12:56 pm Reply with quote
User Joined: 17 Aug 2006 Posts: 213
I'm hoping to really start digging into erlyweb this week, so expect more and more questions Smile

So far I have these:

1. .beam only deployment

Is it possible to deploy an Erlyweb application only as a set of compiled .beam files? Currently Erlyweb requires a recompile every time YAWS is restarted, which leads me to the next question:

2. Startup script

How do you handle Server/YAWS/MySQL restarts? Currently you need to call an erlydb:start and then an erlyweb:compile when Yaws is restarted. How do you automate this? How would you handle MySQL connect failures?

3. Weird setup questions

I want to make a crazy setup on my site. I want to make all URLs as memorable as possible. So, instead of a http://site/article/article_title I want to have http://site/article_title. This is easy - just return an ewc tuple from hook/1.

However, there's the backend, user profiles and so on. I want to move them off to subdomains. For instance, I want http://profile.site.com/ to call the index method of the profile controller. That is, make http://site.com/profile/user_id work as http://profile.site.com/user_id.

How would you set up such a thing?


Thank you in advance.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "erlyweb" group.
To post to this group, send email to erlyweb@googlegroups.com
To unsubscribe from this group, send email to erlyweb-unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/erlyweb?hl=en
-~----------~----~----~----~------~----~------~--~---

Post recived from mailinglist
View user's profile Send private message
dmitriid
Posted: Mon Feb 11, 2008 5:16 pm Reply with quote
User Joined: 17 Aug 2006 Posts: 213
David King wrote:
Quote:
Quote:
Is it possible to deploy an Erlyweb application only as a set of compiled .beam files? Currently Erlyweb requires a recompile every time YAWS is restarted, which leads me to the next question: [/code]
Yes. It only requires a re-compile because it doesn't default to having the .beams in the code-path, and a re-compile forces a load of the .beam regardless of its location. If you just pass "-pa $BEAM_PATH" to yaws or erl, you won't need the source. That said, it doesn't hurt to include the source anyway, in case you need to make a last minute "NOW NOW NOW!" security fix in shorter time than would be required to mess with your source control system. [/code]
And that would screw up the control system of course Smile
Quote:
[/code]
Quote:
How do you handle Server/YAWS/MySQL restarts? Currently you need to call an erlydb:start and then an erlyweb:compile when Yaws is restarted. How do you automate this? How would you handle MySQL connect failures? [/code]
I have a wrotit.app file with all of my configuration, and I do an "application:start(wrotit)" (which can also be done from the command line). 11 start() -> start([],[]). 12 start(_Type, _Args) -> 13 %% compile first (if nothing else, this at least loads in my 14 %% modules) 15 compile(), 16 17 %% bring up yaws (doesn't appear in my supervisor hierarchy) 18 wrotit_init:start_yaws(), 19 20 %% bring up psql, required by erlydb_psql 21 start_psql_driver(), 22 23 %% my main supervisor will be returned 24 wrotit_supervisor:start_link(). [/code]

I guess compile should be called after the database is up, shouldn't it?

Quote:
Of course, the reverse is done in 'stop'. I start wrotit from 'erl', not from 'yaws', and then I bring up yaws in "embedded mode". All of the connect failures, etc, can be handled right here, like "if I couldn't connect, throw a 'Oh noes!' exception", or whatever your application can do in lieu of a database connection. In my application, if I can't get a database connection, I'm totally screwed, so I just throw an exception. [/code]
Thanks for the tip!
Quote:
[/code]
Quote:
I want to make a crazy setup on my site. I want to make all URLs as memorable as possible. So, instead of a http://site/article/article_title I want to have http://site/article_title. This is easy - just return an ewc tuple from hook/1. However, there's the backend, user profiles and so on. I want to move them off to subdomains. For instance, I want http://profile.site.com/ to call the index method of the profile controller. That is, make http://site.com/profile/user_id work as http://profile.site.com/user_id. How would you set up such a thing? [/code]
You'll have to take a look at what's passed in the yaws_arg (the argument to hook/1) and see if you can parse out the domain that's been requested, and return the {ewc} as appropriate. Basically, you're re-implementing the logic in erlyweb:get_initial_ewc, which some frameworks like Pylons and Rails call "routing". [/code]
Yup, routing it is Smile Though it seems that I like erlyweb's approach much more.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "erlyweb" group.
To post to this group, send email to erlyweb@googlegroups.com
To unsubscribe from this group, send email to erlyweb-unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/erlyweb?hl=en
-~----------~----~----~----~------~----~------~--~---

Post recived from mailinglist
View user's profile Send private message
ketralnis
Posted: Mon Feb 11, 2008 5:45 pm Reply with quote
User Joined: 20 Jul 2007 Posts: 151 Location: San Francisco, CA
> Is it possible to deploy an Erlyweb application only as a set of
> compiled .beam files? Currently Erlyweb requires a recompile every
> time YAWS is restarted, which leads me to the next question:

Yes. It only requires a re-compile because it doesn't default to
having the .beams in the code-path, and a re-compile forces a load of
the .beam regardless of its location. If you just pass "-pa
$BEAM_PATH" to yaws or erl, you won't need the source.

That said, it doesn't hurt to include the source anyway, in case you
need to make a last minute "NOW NOW NOW!" security fix in shorter time
than would be required to mess with your source control system.

> How do you handle Server/YAWS/MySQL restarts? Currently you need to
> call an erlydb:start and then an erlyweb:compile when Yaws is
> restarted. How do you automate this? How would you handle MySQL
> connect failures?

I have a wrotit.app file with all of my configuration, and I do an
"application:start(wrotit)" (which can also be done from the command
line).

11 start() -> start([],[]).
12 start(_Type, _Args) ->
13 %% compile first (if nothing else, this at least loads in my
14 %% modules)
15 compile(),
16
17 %% bring up yaws (doesn't appear in my supervisor hierarchy)
18 wrotit_init:start_yaws(),
19
20 %% bring up psql, required by erlydb_psql
21 start_psql_driver(),
22
23 %% my main supervisor will be returned
24 wrotit_supervisor:start_link().

Of course, the reverse is done in 'stop'. I start wrotit from 'erl',
not from 'yaws', and then I bring up yaws in "embedded mode". All of
the connect failures, etc, can be handled right here, like "if I
couldn't connect, throw a 'Oh noes!' exception", or whatever your
application can do in lieu of a database connection. In my
application, if I can't get a database connection, I'm totally
screwed, so I just throw an exception.

> I want to make a crazy setup on my site. I want to make all URLs as
> memorable as possible. So, instead of a http://site/article/article_title
> I want to have http://site/article_title. This is easy - just
> return an ewc tuple from hook/1.
> However, there's the backend, user profiles and so on. I want to
> move them off to subdomains. For instance, I want http://profile.site.com/
> to call the index method of the profile controller. That is, make http://site.com/profile/user_id
> work as http://profile.site.com/user_id.
> How would you set up such a thing?

You'll have to take a look at what's passed in the yaws_arg (the
argument to hook/1) and see if you can parse out the domain that's
been requested, and return the {ewc} as appropriate. Basically, you're
re-implementing the logic in erlyweb:get_initial_ewc, which some
frameworks like Pylons and Rails call "routing".


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "erlyweb" group.
To post to this group, send email to erlyweb@googlegroups.com
To unsubscribe from this group, send email to erlyweb-unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/erlyweb?hl=en
-~----------~----~----~----~------~----~------~--~---

Post recived from mailinglist
View user's profile Send private message AIM Address

Display posts from previous:  

All times are GMT
Page 1 of 1
This forum is locked: you cannot post, reply to, or edit topics.

Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum