Verified Commit 8f4fbc34 authored by Aral Balkan's avatar Aral Balkan
Browse files

Closes #232: site status now displays statistics URL if daemon active

parent 5858aa6c
......@@ -12,6 +12,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
- Status command now displays daemon details if daemon is enabled (#36).
- Status command now displays statistics URL if daemon is active (#232).
- Implement shorter custom ssh connection timeout for sync for when the host exists but you are not authorised to connect to it.
Previously, the timeout was the default TCP connection timeout of 120 seconds which would make it look like the process had hanged. The new timeout is 5 seconds, which provides timely feedback.
......
......@@ -33,8 +33,14 @@ function status () {
if (daemonDetails !== null) {
const textColour = isActive ? 'green' : 'red'
if (isActive) {
console.log(`\n Stats : ${clr(daemonDetails.statisticsUrl, textColour)}`)
}
console.log(`\n Path : ${clr(daemonDetails.pathBeingServed, textColour)}`)
console.log(` Domain : ${clr(daemonDetails.optionalOptions.domain, 'yellow') || clr(crossPlatformHostname, daemonDetails.optionalOptions.skipDomainReachabilityCheck && isActive ? 'yellow' : textColour)}`)
console.log(` Account: ${clr(daemonDetails.account, textColour)}`)
if (daemonDetails.optionalOptions.aliases !== null) {
......
......@@ -8,10 +8,12 @@
//
//////////////////////////////////////////////////////////////////////
const os = require('os')
const fs = require('fs')
const path = require('path')
const childProcess = require('child_process')
const fs = require('fs')
const path = require('path')
const childProcess = require('child_process')
const crossPlatformHostname = require('@small-tech/cross-platform-hostname')
const Site = require('../../')
function status () {
......@@ -61,6 +63,12 @@ function status () {
const aliases = (_aliases = /--aliases=(.*?)(\s|--|$)/.exec(execStart)) === null ? null : _aliases[1].split(',')
const skipDomainReachabilityCheck = execStart.includes('--skip-domain-reachability-check')
let statisticsUrl = null
if (isActive) {
const statisticsPath = fs.readFileSync(path.join(Site.settingsDirectory, 'statistics-route'), 'utf-8')
statisticsUrl = `https://${domain || crossPlatformHostname}${statisticsPath}`
}
const optionalOptions = {
domain,
aliases,
......@@ -70,6 +78,7 @@ function status () {
daemonDetails = {
account,
siteJSBinary,
statisticsUrl,
pathBeingServed,
optionalOptions
}
......
......@@ -44,7 +44,6 @@ const decache = require('decache')
const prepareRequest = require('bent')
const clr = require('./lib/clr')
const cli = require('./bin/lib/cli')
const serve = require('./bin/commands/serve')
const Stats = require('./lib/Stats')
const asyncForEach = require('./lib/async-foreach')
const errors = require('./lib/errors')
......@@ -1576,5 +1575,4 @@ class Site {
}
}
module.exports = Site
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment