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/), ...@@ -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 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. - 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. 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 () { ...@@ -33,8 +33,14 @@ function status () {
if (daemonDetails !== null) { if (daemonDetails !== null) {
const textColour = isActive ? 'green' : 'red' 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(`\n Path : ${clr(daemonDetails.pathBeingServed, textColour)}`)
console.log(` Domain : ${clr(daemonDetails.optionalOptions.domain, 'yellow') || clr(crossPlatformHostname, daemonDetails.optionalOptions.skipDomainReachabilityCheck && isActive ? 'yellow' : textColour)}`) console.log(` Domain : ${clr(daemonDetails.optionalOptions.domain, 'yellow') || clr(crossPlatformHostname, daemonDetails.optionalOptions.skipDomainReachabilityCheck && isActive ? 'yellow' : textColour)}`)
console.log(` Account: ${clr(daemonDetails.account, textColour)}`) console.log(` Account: ${clr(daemonDetails.account, textColour)}`)
if (daemonDetails.optionalOptions.aliases !== null) { if (daemonDetails.optionalOptions.aliases !== null) {
......
...@@ -8,10 +8,12 @@ ...@@ -8,10 +8,12 @@
// //
////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////
const os = require('os') const fs = require('fs')
const fs = require('fs') const path = require('path')
const path = require('path') const childProcess = require('child_process')
const childProcess = require('child_process') const crossPlatformHostname = require('@small-tech/cross-platform-hostname')
const Site = require('../../')
function status () { function status () {
...@@ -61,6 +63,12 @@ function status () { ...@@ -61,6 +63,12 @@ function status () {
const aliases = (_aliases = /--aliases=(.*?)(\s|--|$)/.exec(execStart)) === null ? null : _aliases[1].split(',') const aliases = (_aliases = /--aliases=(.*?)(\s|--|$)/.exec(execStart)) === null ? null : _aliases[1].split(',')
const skipDomainReachabilityCheck = execStart.includes('--skip-domain-reachability-check') 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 = { const optionalOptions = {
domain, domain,
aliases, aliases,
...@@ -70,6 +78,7 @@ function status () { ...@@ -70,6 +78,7 @@ function status () {
daemonDetails = { daemonDetails = {
account, account,
siteJSBinary, siteJSBinary,
statisticsUrl,
pathBeingServed, pathBeingServed,
optionalOptions optionalOptions
} }
......
...@@ -44,7 +44,6 @@ const decache = require('decache') ...@@ -44,7 +44,6 @@ const decache = require('decache')
const prepareRequest = require('bent') const prepareRequest = require('bent')
const clr = require('./lib/clr') const clr = require('./lib/clr')
const cli = require('./bin/lib/cli') const cli = require('./bin/lib/cli')
const serve = require('./bin/commands/serve')
const Stats = require('./lib/Stats') const Stats = require('./lib/Stats')
const asyncForEach = require('./lib/async-foreach') const asyncForEach = require('./lib/async-foreach')
const errors = require('./lib/errors') const errors = require('./lib/errors')
...@@ -1576,5 +1575,4 @@ class Site { ...@@ -1576,5 +1575,4 @@ class Site {
} }
} }
module.exports = 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