Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TIMOB-16387] LiveView: unexpected behavior when running LiveView on device without terminating the existing launch #76

Merged
merged 3 commits into from
Feb 15, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 7 additions & 2 deletions hook/lvhook.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ require('shelljs/global');

var debug = require('debug')('liveview:clihook'),
path = require('path'),
http = require('http'),
join = path.join,
fs = require('fs'),
util = require('util');
Expand Down Expand Up @@ -54,7 +55,7 @@ exports.init = function(logger, config, cli) {

var srcFile = data.args[0];
var destFile = data.args[1];
if (join(RESOURCES_DIR, 'app.js') === srcFile ||
if (join(RESOURCES_DIR, 'app.js') === srcFile ||
(new RegExp('^' + RESOURCES_DIR.replace(/\\/g, '/') + '(\/(android|ipad|ios|iphone))?\/app.js$').test(srcFile.replace(/\\/g, '/')))) {
data.args[0] = join(tempdir(), 'liveview.js');
}
Expand Down Expand Up @@ -123,7 +124,11 @@ exports.init = function(logger, config, cli) {
*/

cli.addHook('build.post.compile', function(build, finished) {
exec(escape(__dirname, '../bin/liveview-server') + ' stop --no-colors');
// kill running server via fserver http api
http
.get('http://localhost:8324/kill', function(res){})
.on('error', function(e){});

if (cli.argv.liveview) {
debug('Running post:build.post.compile hook');
var binDIR = join(__dirname, '../bin/liveview-server');
Expand Down
22 changes: 18 additions & 4 deletions lib/fserver.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,17 +159,31 @@ FServer.start = function(opts) {
var filename = join(RESOURCE_DIR, uri);
var overridePath = join(__dirname, 'overrides', uri);


if (uri === '/') {
response.writeHead(200, {
'Content-Type': 'text/plain',
'Project-ID': 'todo'
'Content-Type': 'application/json'
});
response.write('Appcelerator - liveview\n');

var data = {
pid: process.pid,
path: PROJECT_DIR,
uptime: process.uptime(),
alloy: isAlloy
};

response.write(JSON.stringify(data));
response.end();
return;
}

if (uri === '/kill') {
response.end('');
fServer.close();
evtServer.close();
rm('-rf', PID_FILE);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will this work on Windows?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mxia is should. The rm command is from Shell.js that supports windows, mac and linux. Plus I am already using the command elsewhere in LiveView

process.exit(0);
}

debug('Request Headers:', '\n', util.inspect(request.headers), '\n');

filename = (fs.existsSync(overridePath))
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "liveview",
"version": "1.0.2",
"version": "1.0.3",
"description": "Titanium Live Realtime App Development",
"main": "index.js",
"private": true,
Expand Down