1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#![feature(integer_atomics)]
#![deny(warnings, intra_doc_link_resolution_failure)]
#![deny(clippy::all, clippy::pedantic)]
#[macro_use]
extern crate log;
#[macro_use]
extern crate mruby;
#[macro_use]
extern crate rust_embed;
use mruby::eval::MrbEval;
use mruby::{Mrb, MrbError};
use nemesis::{Builder, Error, Mount};
mod assets;
mod foolsgold;
use assets::Assets;
pub fn main() -> Result<(), i32> {
env_logger::Builder::from_env("FOOLSGOLD_LOG").init();
if let Err(err) = spawn() {
error!("Failed to launch nemesis: {}", err);
eprintln!("ERR: {}", err);
Err(1)
} else {
Ok(())
}
}
pub fn spawn() -> Result<(), Error> {
Builder::default()
.add_mount(
Mount::from_rackup("foolsgold", foolsgold::RACKUP, "/fools-gold/shared-nothing")
.with_init(Box::new(interp_init)),
)
.add_mount(
Mount::from_rackup("foolsgold", foolsgold::RACKUP, "/fools-gold/prefork")
.with_init(Box::new(interp_init))
.with_shared_interpreter(Some(150)),
)
.add_static_assets(Assets::all()?)
.serve()
}
fn interp_init(interp: &Mrb) -> Result<(), MrbError> {
foolsgold::init(interp)?;
interp.eval("require 'foolsgold'")?;
Ok(())
}