How does one run a locomotive app without lcm? Where's the app.js?

342 views
Skip to first unread message

AJ ONeal

unread,
Aug 8, 2013, 1:43:09 PM8/8/13
to locomo...@googlegroups.com
How does one run a locomotive app without using the lcm command?

In other words, where is `module.exports = app;` happening?

I just want to do something like `node app.js -p 3000`, but I'm having trouble finding the place for it.

I'm assuming I need to create a file that's something like this, but I can't find documentation for how it's done.

```javascript
(function () {
  'use strict';

  var locomotive = require('locomotive')
    , app
    ;

  app = locomotive.createServer(__directory);

  module.exports = app;
}());
```

Jared Hanson

unread,
Aug 8, 2013, 2:19:37 PM8/8/13
to locomo...@googlegroups.com
Copy the final lines of this file: https://github.com/jaredhanson/locomotive/blob/master/lib/locomotive/cli/server.js#L90

The important bit being locomotive.boot().

In an upcoming version, the "create" generator will create a server.js file with these lines in it.  That will become the preferred way to start the server, rather than using `lcm server`.

Jared



--
You received this message because you are subscribed to the Google Groups "Locomotive" group.
To unsubscribe from this group and stop receiving emails from it, send an email to locomotivejs...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 



--
Jared Hanson <http://jaredhanson.net/>

AJ ONeal

unread,
Aug 8, 2013, 2:46:56 PM8/8/13
to locomo...@googlegroups.com
Thanks, I actually just found that and now have it almost working.

Because the server isn't available until after some async stuff happens, I had to manually edit the code with `this.app = app` at the end of the function.

I'm using (my own) connect-vhoster, which doesn't allow async apps. I suppose I need to change that.

```javascript
(function () {
  'use strict';

  var locomotive = require('locomotive')
    , dir = __dirname
    , env = 'production'
    ;

  // node_modules/locomotive/lib/locomotive/index.js
  // has been manually edited to export `app` before its time
  locomotive.boot(dir, env, function(err, server) {
  });
  module.exports = locomotive.app;
}());
```

--
You received this message because you are subscribed to a topic in the Google Groups "Locomotive" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/locomotivejs/9d2AAgvQSS0/unsubscribe.
To unsubscribe from this group and all its topics, send an email to locomotivejs...@googlegroups.com.

G.H. Naylor

unread,
Nov 13, 2013, 9:09:20 PM11/13/13
to locomo...@googlegroups.com
This is exciting news. Is there an ETA on this feature?

Arjon Buikstra

unread,
Nov 29, 2013, 11:58:45 AM11/29/13
to locomo...@googlegroups.com
I've just migrated an existing project stub to locomotive and didn't want my coworkers to have to change their runtime configurations.. So I did this in app.js:

    var locomotive = require('locomotive');
    options = {
        app : '',
        address : "localhost",
        port : 3000,
        env : process.env.NODE_ENV || "development"
    };
    locomotive.cli.server(options.app || process.cwd(), options.address, options.port, options.env, options);

Should I be using boot instead?
Reply all
Reply to author
Forward
0 new messages