Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2ed3bb6
commit ce8151b
Showing
9 changed files
with
188 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
$(OHM)=ohm # The name of the 'ohm' tool to be invoked | ||
|
||
all: | ||
$(OHM) assets # Build all the assets, place them in '/_build' | ||
$(OHM) build # Build the ocaml code found in '/ocaml', generates '/ocaml/main.byte' | ||
|
||
#Copy the server binary over to the correct path | ||
cp ocaml/main.byte www/server | ||
mv www/server www/server.real | ||
|
||
# Perform the deployment | ||
www/server.real --put | ||
www/server.real --reset | ||
|
||
clean: | ||
$(OHM) clean |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<*> or <**/*>: package(camlp4), syntax(camlp4o), custom-pp, package(curl), package(netcgi2), package(netclient), package(batteries), package(sha), package(netstring), package(xmlm) | ||
<*>: include | ||
<gen>: include | ||
<plugins/*>: include |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
(* © 2012 RunOrg *) | ||
|
||
open Ohm | ||
open BatPervasives | ||
|
||
module Main = Main.Make(O.Reset) | ||
let _ = Main.run (Some O.run_async) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
open Ocamlbuild_plugin | ||
|
||
let path_to_pp = "../ohm/pp.cmo" | ||
|
||
let _ = dispatch begin function | ||
| After_rules -> | ||
flag ["ocamldep"; "custom-pp"] (S[A"-ppopt";A path_to_pp]); | ||
flag ["compile"; "custom-pp"] (S[A"-ppopt";A path_to_pp]); | ||
| _ -> () | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
(* Ohm is © 2012 Victor Nicollet *) | ||
|
||
open Ohm | ||
open Ohm.Universal | ||
open BatPervasives | ||
|
||
(* Environment and basic configuration ---------------------------------------------------------------------- *) | ||
|
||
let environment = `Dev | ||
|
||
let env = match environment with | ||
| `Prod -> "prod" | ||
| `Dev -> "dev" | ||
|
||
let () = | ||
Configure.set `Log begin match Ohm.Util.role with | ||
| `Put | ||
| `Reset -> "-" | ||
| `Bot | ||
| `Web -> "/var/log/ohm/" ^ env ^ ".log" | ||
end | ||
|
||
(* Basic databases ------------------------------------------------------------------------------------------ *) | ||
|
||
let db name = Printf.sprintf "%s-%s" env name | ||
|
||
module ConfigDB = CouchDB.Convenience.Database(struct let db = db "config" end) | ||
module Reset = Reset.Make(ConfigDB) | ||
|
||
(* Context management --------------------------------------------------------------------------------------- *) | ||
|
||
type i18n = Asset_AdLib.key | ||
|
||
class ctx adlib = object | ||
inherit CouchDB.init_ctx | ||
inherit Async.ctx | ||
inherit [i18n] AdLib.ctx adlib | ||
end | ||
|
||
let ctx = function | ||
| `FR -> new ctx Asset_AdLib.fr | ||
|
||
let put action = | ||
if Ohm.Util.role = `Put then | ||
ignore (Ohm.Run.eval (ctx `FR) action) | ||
|
||
type 'a run = (ctx,'a) Run.t | ||
|
||
module AsyncDB = CouchDB.Convenience.Config(struct let db = db "async" end) | ||
module Async = Ohm.Async.Make(AsyncDB) | ||
|
||
let async : ctx Async.manager = new Async.manager | ||
|
||
let run_async () = | ||
async # run (fun () -> ctx `FR) | ||
|
||
(* Action management ---------------------------------------------------------------------------------------- *) | ||
|
||
let domain = match environment with | ||
| `Prod -> "project.com" | ||
| `Dev -> "project.local" | ||
|
||
let cookies = "." ^ domain | ||
|
||
let core = Action.Convenience.single_domain_server ~cookies domain | ||
|
||
let action f req res = | ||
Run.with_context (ctx `FR) (f req res) | ||
|
||
let register s u a body = | ||
Action.register s u a (action body) | ||
|
||
let declare s u a = | ||
let endpoint, define = Action.declare s u a in | ||
endpoint, action |- define | ||
|
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters