using concurrent::Actorusing util::AbstractMainusing util::Argusing util::Optusing web::WebModusing wisp::WispService** Call to run a 'BedSheet' web application from the command line.** ** pre>** C:\> fan afBedSheet [-env <env>] [-proxy] [-noTransDeps] <appModule> <port>** <pre** ** Where:** env: (optional) The environment to start BedSheet in -> dev|test|prod** proxy: (optional) Starts a dev proxy and launches the real web app on (<port> + 1)** noTransDeps: (optional) Do not load transitive dependencies.** appModule: The qname of the AppModule or pod which configures the BedSheet web app** port: The HTTP port to run the app onclass Main : AbstractMain { @Opt { help="Starts a proxy and launches the real web app on (<port> + 1)"}private Bool proxy @Opt { help="Do not load transitive dependencies."}private Bool noTransDeps @Opt { help="The environment to start BedSheet in -> dev|test|prod"}private Str? env @Arg { help="The qname of the AppModule or pod which configures the BedSheet web app"}private Str? appModule// I could make this an @Opt but then it'd break backwards dependency and I'd have to update all// the docs - meh! @Arg { help="The HTTP port to run the app on"}private Int port** Run baby, run! @NoDoc // point!override Int run(){ mod := (WebMod)(proxy ? ProxyMod(appModule, port, noTransDeps, env) : BedSheetWebMod(appModule, port, options))// if WISP reports "sys::IOErr java.net.SocketException: Unrecognized Windows Sockets error: 10106: create"// then check all your ENV vars are being passed to java.// see http://forum.springsource.org/showthread.php?106504-Error-running-grails-project-on-alternative-port-with-STS2-6-0&highlight=Unrecognized%20Windows%20Sockets%20error willow := WispService {it.port=this.port; it.root=mod }return startWisp(willow)} @NoDocvirtual Str:Obj? options(){ options := Utils.makeMap(Str#, Obj?#) options["startProxy"] = proxy options["noTransDeps"] = noTransDepsreturn options}private Int startWisp(WispService wisp){ Env.cur.addShutdownHook |->| { shutdownWisp(wisp)} wisp.install wisp.start// give services a chance to init themselves Actor.sleep(2sec)// exit if wisp didn't startif(!wisp.isRunning){ Env.cur.err.printLine("Service '${wisp.typeof}' did not start") Env.cur.exit(69)}// all good, so lets hang around for a bit... Actor.sleep(Duration.maxVal)return 0}privatestatic Void shutdownWisp(WispService wisp){ wisp.stop wisp.uninstall// log the cause, 'cos Service doesn't!!// @see http://fantom.org/sidewalk/topic/2201if(wisp.root is BedSheetWebMod){ bsMod := (BedSheetWebMod) wisp.rootif(bsMod.startupErr?.cause != null) Env.cur.err.printLine("\nCausing Err:\n\n${bsMod.startupErr.cause.traceToStr}")}}}