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

Tilestream starts properly even if HOME is unset, by using os.homedir() #155 #158

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion commands/global.bones
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
var os = reuqire('os');
var path = require('path');

Bones.Command.options['uiPort'] = {
Expand Down Expand Up @@ -25,7 +26,7 @@ Bones.Command.options['subdomains'] = {
Bones.Command.options['tiles'] = {
'title': 'tiles=[path]',
'description': 'Path to tiles directory.',
'default': path.join(process.env.HOME, 'Documents', 'MapBox', 'tiles')
'default': path.join(os.homedir(), 'Documents', 'MapBox', 'tiles')
};

Bones.Command.options['accesslog'] = {
Expand Down
8 changes: 2 additions & 6 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
#!/usr/bin/env node
var os = require('os');

// increase the libuv threadpool size to 1.5x the number of logical CPUs.
process.env.UV_THREADPOOL_SIZE = Math.ceil(Math.max(4, require('os').cpus().length * 1.5));
process.env.UV_THREADPOOL_SIZE = Math.ceil(Math.max(4, os.cpus().length * 1.5));

process.title = 'tilestream';

if (process.platform === 'win32') {
// HOME is undefined on windows
process.env.HOME = process.env.USERPROFILE;
}

var tilelive = require('tilelive');
require('mbtiles').registerProtocols(tilelive);

Expand Down
5 changes: 4 additions & 1 deletion lib/bootstrap.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
var fs = require('fs');
var os = require('os');
var path = require('path');
var util = require('util');
var existsSync = require('fs').existsSync || require('path').existsSync;

let homedir = os.homedir()

function mkdirpSync(p, mode) {
var ps = path.normalize(p).split('/');
var created = [];
Expand All @@ -20,7 +23,7 @@ module.exports = function(settings, callback) {
try {
fs.statSync(settings.tiles);
} catch (Exception) {
if (!process.env.HOME) {
if (!homedir) {
console.log('Could not locate home directory. Set location manually with the --tiles option.');
process.exit(1);
} else {
Expand Down