Mike Gerwitz

Activist for User Freedom

aboutsummaryrefslogtreecommitdiffstats
path: root/bin
diff options
context:
space:
mode:
authorMike Gerwitz <mike.gerwitz@ryansg.com>2019-11-11 16:57:24 -0500
committerMike Gerwitz <mike.gerwitz@ryansg.com>2019-11-12 16:21:00 -0500
commitd0b2a4ce73ce47030e1bc49e9b68a2bad9069ac3 (patch)
tree93fa98dc22ca58c136bd23fa8b5cb14f55ee4cfd /bin
parente450bbb3d69df34ba2da62fe78b7ef65bfab7efc (diff)
downloadliza-d0b2a4ce73ce47030e1bc49e9b68a2bad9069ac3.tar.gz
liza-d0b2a4ce73ce47030e1bc49e9b68a2bad9069ac3.tar.bz2
liza-d0b2a4ce73ce47030e1bc49e9b68a2bad9069ac3.zip
bin/server: Convert to TypeScript
Diffstat (limited to 'bin')
-rw-r--r--bin/server.ts45
1 files changed, 26 insertions, 19 deletions
diff --git a/bin/server.ts b/bin/server.ts
index ec93fb7..0e8445a 100644
--- a/bin/server.ts
+++ b/bin/server.ts
@@ -1,7 +1,7 @@
/**
* Start the Liza Server
*
- * Copyright (C) 2017 R-T Specialty, LLC.
+ * Copyright (C) 2010-2019 R-T Specialty, LLC.
*
* This file is part of the Liza Data Collection Framework.
*
@@ -19,19 +19,12 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-'use strict';
+import fs = require( 'fs' );
+import path = require( 'path' );
-const fs = require( 'fs' );
-const path = require( 'path' );
-
-const {
- conf: {
- ConfLoader,
- ConfStore,
- },
- server,
- version,
-} = require( '../' );
+import { ConfLoader } from "../src/conf/ConfLoader";
+import { ConfStore } from "../src/conf/ConfStore";
+import * as version from "../src/version";
// kluge for now
const conf_path = (
@@ -42,7 +35,7 @@ const conf_path = (
const conf_dir = path.dirname( conf_path );
-ConfLoader( fs, ConfStore )
+new ConfLoader( fs, ConfStore )
.fromFile( conf_path )
.then( conf => Promise.all( [
conf.get( 'name' ),
@@ -70,12 +63,12 @@ ConfLoader( fs, ConfStore )
* Produce an absolute path if `path` is absolute, otherwise a path relative
* to the configuration directory
*
- * @param {string} conf_path configuration path (for relative `path`)
- * @param {string} path path to resolve
+ * @param conf_path - configuration path (for relative `path`)
+ * @param path - path to resolve
*
* @return resolved path
*/
-function _resolvePath( conf_path, path )
+function _resolvePath( conf_path: string, path: string ): string
{
return ( path[ 0 ] === '/' )
? path
@@ -83,7 +76,12 @@ function _resolvePath( conf_path, path )
}
-function writePidFile( pid_path )
+/**
+ * Write process id (PID) file
+ *
+ * @param pid_path - path to pid file
+ */
+function writePidFile( pid_path: string ): void
{
fs.writeFile( pid_path, process.pid );
@@ -91,7 +89,16 @@ function writePidFile( pid_path )
}
-function greet( name, pid_path )
+/**
+ * Output greeting
+ *
+ * The greeting contains the program name, version, configuration path,
+ * and PID file path.
+ *
+ * @param name - program name
+ * @param pid_path - path to PID file
+ */
+function greet( name: string, pid_path: string ): void
{
console.log( `${name} (liza-${version})`);
console.log( `Server configuration: ${conf_path}` );