How to use the hostname function from os

Find comprehensive JavaScript os.hostname code examples handpicked from public code repositorys.

36
37
38
39
40
41
42
43
44
45
class Config {
  constructor (options = {}) {
    const enabled = coalesce(options.enabled, DD_PROFILING_ENABLED, true)
    const env = coalesce(options.env, DD_ENV)
    const service = options.service || DD_SERVICE || 'node'
    const host = os.hostname()
    const version = coalesce(options.version, DD_VERSION)
    const functionname = process.env.AWS_LAMBDA_FUNCTION_NAME
    // Must be longer than one minute so pad with five seconds
    const flushInterval = coalesce(options.interval, Number(DD_PROFILING_UPLOAD_PERIOD) * 1000, 65 * 1000)
fork icon241
star icon444
watch icon462

+ 2 other calls in file

703
704
705
706
707
708
709
710
711
712
    }, this.etcd_start_timeout, 0);
}

get_mon_state()
{
    return { ip: this.local_ips(), hostname: os.hostname() };
}

async get_lease()
{
fork icon12
star icon71
watch icon7

211
212
213
214
215
216
217
218
219
220
var self = this;
var now = Date.now() / 1000;
if (now - this.reqMaxDumpLast < this.reqMaxDumpDebounce) return;
this.reqMaxDumpLast = now;

var dump_file = this.reqMaxDumpDir + '/req-dump-' + os.hostname() + '-' + process.pid + '-' + Date.now().toString(36) + '.json';
var json = this.getStats();
json.requests = {};

for (var id in this.requests) {
fork icon2
star icon7
watch icon0

4519
4520
4521
4522
4523
4524
4525
4526
4527
4528
let res = await fetchCmd(`${LICENSE_HOST}/licenses/trial`, {
    method: 'post',
    body: JSON.stringify({
        version: packageData.version,
        app: '@postalsys/emailengine-app',
        hostname: os.hostname() || 'localhost',
        url: (await settings.get('serviceUrl')) || ''
    }),
    headers
});
fork icon113
star icon0
watch icon16

119
120
121
122
123
124
125
126
127
128
}
// Called by HUB when user clicks on the Hosts page
function OnPing(id) {
    log("ping => " + microServiceBusNode.InboundServices().length + " active service(s)");

    _client.invoke('pingResponse', settingsHelper.settings.nodeName, os.hostname(), "Online", id, false);

}
// Called by HUB to receive all active services
/* istanbul ignore next */
fork icon4
star icon0
watch icon0

+ 9 other calls in file

195
196
197
198
199
200
201
202
203
204
205
206
    }
}


exports.health = async (req, res, next) => {
    try {
        const hostname = os.hostname();


        const upgradeFilePath = path.join(process.cwd(), UPGRADE_FILE_NAME);
        const upgradeFileExists = await (async () => {
            try {
fork icon0
star icon7
watch icon3

17
18
19
20
21
22
23
24
25
26
27
    json_logs ? consoleTransportJson : consoleTransport,
];


let tracer;
let sentryParams = {
    serverName: os.hostname(),
    dsn: process.env.SENTRY_DSN,
    environment: process.env.SENTRY_ENVIRONMENT,
    debug: process.env.NODE_ENV !== 'production',
    release: process.env.SENTRY_RELEASE,
fork icon0
star icon3
watch icon210

36
37
38
39
40
41
42
43
44
tracker = new gitTracker(currentDir);
tracker.createGitFolders();

// get user and hostname for regex matching
var user = os.userInfo().username;
var hostname = os.hostname();
if(hostname.indexOf(".") > 0){
	hostname = hostname.substring(0, hostname.indexOf("."));
}
fork icon0
star icon1
watch icon2

2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
    value: process.version
});

rows.push({
    name: 'Hostname',
    value: os.hostname()
});

rows.push({
    name: 'Platform',
fork icon0
star icon1
watch icon1

29
30
31
32
33
34
35
36
37
38
const context = await botInstance.createBrowserContext(browser, requestDescription)
const page = await botInstance.createPageByContext(context)
const contextId = context.id
const result = await botInstance.runInstructions(contextId, page, data)
let response = {
    hostname: os.hostname(),
    code: 200,
    requestId: requestId,
    contextId: result['contextId'],
    instructionsMessage: result['message'],
fork icon0
star icon0
watch icon0

+ 11 other calls in file

58
59
60
61
62
63
64
65
66
67
    REQUEST_PROTOCOL: req.protocol,
    REQUEST_METHOD: req.method,
    SERVER_NAME: req.hostname,
    BASE_URL: req.headers && req.protocol + '://' + req.headers['host'],
    URL: urlParts[0],
    HOSTNAME: os.hostname()
};

if (req.headers) {
    for (let header in req.headers) {
fork icon0
star icon0
watch icon1

42
43
44
45
46
47
48
49
50
51
log.silly('createChecksumJsFile', 'path to checksum.js folder = '+filepath);

// build JSON checksum object
checksumJson.checksum = checksum;   // www folder checksum value
checksumJson.date = now.getTime();  // Time in milliseconds
checksumJson.machine = os.hostname();

// build the file contents
var contents = 'var WL_CHECKSUM = '+JSON.stringify(checksumJson);
contents += '\n/* Date: ' + now.toString() + ' */';
fork icon0
star icon0
watch icon1

22
23
24
25
26
27
28
29
30
31
32
}


function getUsername() {
	var cfg = getLocalConfig();
	if(!cfg){
		return os.hostname();
	}
	if(cfg.username){
		return (cfg.username + '').trim();
	}
fork icon0
star icon0
watch icon2

20
21
22
23
24
25
26
27
28
29
// var username
// if (process.env.REPL_OWNER != undefined) {
//     username = process.env.REPL_OWNER
// } else {
//     if (os.hostname() != null || os.hostname() != undefined) {
//         username = os.hostname()
//     } else {
//         username = os.userInfo().username
//     }
// }
fork icon0
star icon0
watch icon1

+ 5 other calls in file

2
3
4
5
6
7
8
9
10
11
12
console.log('운영체제 정보---------------------------------');
console.log('os.arch():', os.arch());
console.log('os.platform():', os.platform());
console.log('os.type():', os.type());
console.log('os.uptime():', os.uptime());
console.log('os.hostname():', os.hostname());
console.log('os.release():', os.release());


console.log('경로------------------------------------------');
console.log('os.homedir():', os.homedir());
fork icon0
star icon0
watch icon0

+ 2 other calls in file

2
3
4
5
6
7
8
9
10
11
12
console.log('운영체제 정보 --------------------');
console.log('os.arch(): ', os.arch());
console.log('os.platform(): ', os.platform());
console.log('os.type(): ', os.type());
console.log('os.uptime(): ', os.uptime());
console.log('os.hostname(): ', os.hostname());
console.log('os.release(): ', os.release());


console.log('경로 --------------------');
console.log('os.homedir(): ', os.homedir());
fork icon0
star icon0
watch icon0