| Author |
Message |
|
| dmitriid |
Posted: Thu Aug 23, 2007 6:13 am |
|
|
|
User
Joined: 17 Aug 2006
Posts: 213
|
Most frameworks usually have a config directory where, among other
things resides information about database connection.
My idea is that instead of manually typing erlydb:start(Options),
erlyweb:compile(Path, ErlyDbOptions) we could place a db.conf file in a
config directory so that erlyweb:compile/1 could pick up necessary info
from that file and start erlydb and compile the app with necessary options.
--~--~---------~--~----~------------~-------~--~----~
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 |
|
|
| Back to top |
|
| Guest |
Posted: Thu Aug 23, 2007 6:36 am |
|
|
|
Guest
|
Dmitrii 'Mamut' Dimandt wrote:
> Most frameworks usually have a config directory where, among other
> things resides information about database connection.
>
> My idea is that instead of manually typing erlydb:start(Options),
> erlyweb:compile(Path, ErlyDbOptions) we could place a db.conf file in a
> config directory so that erlyweb:compile/1 could pick up necessary info
> from that file and start erlydb and compile the app with necessary options.
>
Yeah, I keep forgetting to start erlydb when I start yaws myself. I like
the idea of placing the config option in the yaws.conf file as shown at
http://blogtrader.net/page/dcaoyuan?entry=from_rails_to_erlyweb_part1
Now, I haven't actually got this working - started then the next day
started working on something else. May be someone who knows more about
yaws can instruct us both on how to get config like,
<server localhost>
port = 8000
listen = 0.0.0.0
docroot = /home/user/myapp/trunk/apps/myapp/www
appmods = </myapp, myapp> <-- NB: change from erlyweb
<opaque>
appname = myapp
hostname = "localhost" <-- db settings
username = "mememe"
password = "pwpwpw"
database = "myapp_development"
</opaque>
</server>
to work.
Jeff.
--~--~---------~--~----~------------~-------~--~----~
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 |
|
|
| Back to top |
|
| dmitriid |
Posted: Thu Aug 23, 2007 6:55 am |
|
|
|
User
Joined: 17 Aug 2006
Posts: 213
|
jm wrote: Quote: Dmitrii 'Mamut' Dimandt wrote: [/code] Quote: Most frameworks usually have a config directory where, among other things resides information about database connection. My idea is that instead of manually typing erlydb:start(Options), erlyweb:compile(Path, ErlyDbOptions) we could place a db.conf file in a config directory so that erlyweb:compile/1 could pick up necessary info from that file and start erlydb and compile the app with necessary options. [/code] Yeah, I keep forgetting to start erlydb when I start yaws myself. I like the idea of placing the config option in the yaws.conf file [/code] I don't really think this is a good idea to place app-specific options in the yaws.conf file. Think of Apache where users rarely have access to .httpdconf files which doesn't stop them from having per-app settings in config directories.
Same with Yaws. When/if it becomes more popular it may very well be the case when users have no access to yaws.conf file.
--~--~---------~--~----~------------~-------~--~----~
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 |
|
|
| Back to top |
|
| dcaoyuan |
Posted: Thu Aug 23, 2007 7:59 pm |
|
|
|
User
Joined: 28 Mar 2007
Posts: 34
|
I agree with you, Dimandt.
Actually, I'm now using a file config/erlyweb.conf to store all these
informations, and in the erlyweb_app.erl, there are functions:
start(SConf) ->
Opaque = SConf#sconf.opaque,
AppName = proplists:get_value("appname", Opaque),
{_I, Pa, Pz, Environment, Dbdriver, Database, Hostname, Username,
Password} = get_conf(),
{ok, Cwd} = file:get_cwd(),
error_logger:info_msg("CWD: ~s~n", [Cwd]),
AddedPa = [{Dir, code:add_patha(Dir)} || Dir <- Pa],
AddedPz = [{Dir, code:add_pathz(Dir)} || Dir <- Pz],
error_logger:info_msg("Add code patha: ~p~n", [AddedPa]),
error_logger:info_msg("Add code pathz: ~p~n", [AddedPz]),
LogFun =
case Environment of
undefined ->
fun ewp_app:db_log/4;
production ->
build_product(),
fun ewp_app:db_dummy_log/4;
development ->
%code:add_pathz("../apps/ewp/src/test"),
fun ewp_app:db_log/4;
Environment ->
fun ewp_app:db_log/4
end,
error_logger:info_msg("Starting app <~s> using database: ~s~n",
[AppName, Database]),
start_db(Dbdriver, Database, Hostname, Username, Password, LogFun).
get_conf() ->
{ok, Confs} = file:consult("config/ewp.conf"),
I = proplists:get_value(i, Confs),
Pa = proplists:get_value(pa, Confs),
Pz = proplists:get_value(pa, Confs),
Environment = proplists:get_value(environment, Confs),
EnvConfs = proplists:get_value(Environment, Confs),
Dbdriver = proplists:get_value(dbdriver, EnvConfs),
Database = proplists:get_value(database, EnvConfs),
Hostname = proplists:get_value(hostname, EnvConfs),
Username = proplists:get_value(username, EnvConfs),
Password = proplists:get_value(password, EnvConfs),
{I, Pa, Pz, Environment, Dbdriver, Database, Hostname, Username, Password}.
start_db(Dbdriver, Database, Hostname, Username, Password, LogFun) ->
erlydb:start(Dbdriver, [{database, Database},
{hostname, Hostname},
{username, Username},
{password, Password},
{logfun, LogFun}]).
build() ->
io:format("Building development version of ewp.~n"),
build(ewp, [debug_info, {d, ewp_debug_flag, true}]).
build_product() ->
io:format("Building product version of ewp.~n"),
build(ewp, [no_debug_info]).
build(AppName, Options) when is_atom(AppName) ->
build(atom_to_list(AppName), Options);
build(AppName, Options) when is_list(AppName) ->
{I, _Pa, _Pz, _Environment, Dbdriver, Database, Hostname,
Username, Password} = get_conf(),
start_db(Dbdriver, Database, Hostname, Username, Password, fun
ewp_app:db_log/4),
compile(AppName, Options ++ [{auto_compile, false}], I, Dbdriver).
%% This is the entrance from erlyweb auto-compilation.
compile(AppName, Options, I, Dbdriver) ->
erlyweb:compile("./apps/" ++ AppName, lists:foldl(
fun(Dir, Acc) ->
[{i, filename:absname(Dir)} | Acc]
end, [], I) ++
[{erlydb_driver, Dbdriver}] ++ Options).
==========
And the config/erlyweb.conf looks like:
========================
{pa, ["bootstrap/ebin",
"apps/ewp/ebin",
"vendor/erlyweb/ebin",
"vendor/eunit/ebin",
"emagick/ebin"]}.
{i, ["vendor",
"apps/ewp/include",
"/usr/local/lib"]}.
{production, [{dbdriver, mysql},
{database, "pole3_production"},
{hostname, "localhost"},
{password, "pwpwpw"},
{username, "mememe"},
]}.
{development, [{dbdriver, mysql},
{database, "pole3_development"},
{hostname, "localhost"},
{password, "pwpwpw"},
{username, "mememe"},
]}.
{test, [{dbdriver, mysql},
{database, "pole3_test"},
{hostname, "localhost"},
{password, "pwpwpw"},
{username, "mememe"},
]}.
{environment, development}.
========================
I'll update my blog after more testing.
On 8/23/07, Dmitrii 'Mamut' Dimandt <dmitriid@gmail.com> wrote:
>
> jm wrote:
> Dmitrii 'Mamut' Dimandt wrote:
>
>
> Most frameworks usually have a config directory where, among other
> things resides information about database connection.
>
> My idea is that instead of manually typing erlydb:start(Options),
> erlyweb:compile(Path, ErlyDbOptions) we could place a db.conf file in a
> config directory so that erlyweb:compile/1 could pick up necessary info
> from that file and start erlydb and compile the app with necessary options.
>
>
> Yeah, I keep forgetting to start erlydb when I start yaws myself. I like
> the idea of placing the config option in the yaws.conf file
> I don't really think this is a good idea to place app-specific options in
> the yaws.conf file. Think of Apache where users rarely have access to
> .httpdconf files which doesn't stop them from having per-app settings in
> config directories.
>
> Same with Yaws. When/if it becomes more popular it may very well be the
> case when users have no access to yaws.conf file.
>
> >
>
--
- Caoyuan
--~--~---------~--~----~------------~-------~--~----~
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 |
|
|
| Back to top |
|
| dmitriid |
Posted: Fri Aug 24, 2007 7:36 am |
|
|
|
User
Joined: 17 Aug 2006
Posts: 213
|
Caoyuan wrote:
> I agree with you, Dimandt.
>
> Actually, I'm now using a file config/erlyweb.conf to store all these
> informations, and in the erlyweb_app.erl, there are functions:
>
Thank you! I was thinking of moving in the same direction, but lack of
time and lack of knowledge stopped me short of doing that.
I guess that the functionality in erlyweb_app.erl could be incorporated
into ErlyWeb itself.
--~--~---------~--~----~------------~-------~--~----~
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 |
|
|
| Back to top |
|
| dcaoyuan |
Posted: Fri Aug 24, 2007 8:57 am |
|
|
|
User
Joined: 28 Mar 2007
Posts: 34
|
I've added a new blog talking about it. The code in blog is a modified
version from our real project, so there may have little bugs.
On 8/24/07, Dmitrii 'Mamut' Dimandt <dmitriid@gmail.com> wrote:
>
> Caoyuan wrote:
> > I agree with you, Dimandt.
> >
> > Actually, I'm now using a file config/erlyweb.conf to store all these
> > informations, and in the erlyweb_app.erl, there are functions:
> >
> Thank you! I was thinking of moving in the same direction, but lack of
> time and lack of knowledge stopped me short of doing that.
>
> I guess that the functionality in erlyweb_app.erl could be incorporated
> into ErlyWeb itself.
>
> >
>
--
- Caoyuan
--~--~---------~--~----~------------~-------~--~----~
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 |
|
|
| Back to top |
|
| dmitriid |
Posted: Fri Aug 24, 2007 9:06 am |
|
|
|
User
Joined: 17 Aug 2006
Posts: 213
|
Hurrah!
)
Caoyuan wrote: Quote: I've added a new blog talking about it. The code in blog is a modified version from our real project, so there may have little bugs. On 8/24/07, Dmitrii 'Mamut' Dimandt <dmitriid@gmail.com> (dmitriid@gmail.com) wrote: [/code] Quote: Caoyuan wrote: [/code] Quote: I agree with you, Dimandt. Actually, I'm now using a file config/erlyweb.conf to store all these informations, and in the erlyweb_app.erl, there are functions: [/code] Thank you! I was thinking of moving in the same direction, but lack of time and lack of knowledge stopped me short of doing that.  I guess that the functionality in erlyweb_app.erl could be incorporated into ErlyWeb itself. [/code] [/code]
--~--~---------~--~----~------------~-------~--~----~
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 |
|
|
| Back to top |
|
| Guest |
Posted: Sat Aug 25, 2007 12:36 am |
|
|
|
Guest
|
Caoyuan wrote:
> I've added a new blog talking about it. The code in blog is a modified
> version from our real project, so there may have little bugs.
>
Am I right in guessing that http://blogtrader.org/page/dcaoyuan is your
blog (there wasn't a link in your last email). Anyway, thanks for the
write up we need more people writing about the various ways to do things
in erlyweb. Makes my life easier for starters if I don't have to
re-invent the wheel. Plus I sure I'd end up with a cart wheel .
Heading off topic. Found
http://blogtrader.net/page/dcaoyuan?entry=support_vector_machine_for_blogtrader
where you discuss SVM. Are you still using this approach? Is
Staticistal Machine Learning (SML) proving useful in your problem
domain? SML is one of those areas I find interesting, but never seem to
be able to get around to studying or finding away to brake into. Do you
still recommend the books you have listed?
Jeff.
--~--~---------~--~----~------------~-------~--~----~
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 |
|
|
| Back to top |
|
| dcaoyuan |
Posted: Sat Aug 25, 2007 6:27 am |
|
|
|
User
Joined: 28 Mar 2007
Posts: 34
|
On 8/25/07, jm <jeffm@ghostgun.com> wrote:
>
> Caoyuan wrote:
> > I've added a new blog talking about it. The code in blog is a modified
> > version from our real project, so there may have little bugs.
> >
>
> Am I right in guessing that http://blogtrader.org/page/dcaoyuan is your
> blog (there wasn't a link in your last email).
Yes. They may be better way to handle these issues, I just wrote down
for beginner. At least The beginnger will kow how to begin to handle
these issues.
> Anyway, thanks for the
> write up we need more people writing about the various ways to do things
> in erlyweb. Makes my life easier for starters if I don't have to
> re-invent the wheel. Plus I sure I'd end up with a cart wheel .
>
> Heading off topic. Found
> http://blogtrader.net/page/dcaoyuan?entry=support_vector_machine_for_blogtrader
> where you discuss SVM. Are you still using this approach? Is
> Staticistal Machine Learning (SML) proving useful in your problem
> domain? SML is one of those areas I find interesting, but never seem to
> be able to get around to studying or finding away to brake into. Do you
> still recommend the books you have listed?
>
SVM is used in my trading platform, the theory of SML is reasonable,
and the result need a lot of tunning. I like SVM and neural networks
approach too. The books listed there are still the best to learn SVM.
>
> Jeff.
>
> >
>
--
- Caoyuan
--~--~---------~--~----~------------~-------~--~----~
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 |
|
|
| Back to top |
|
|
|
All times are GMT
|
|
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
|
|
|