Skip to content

Commit

Permalink
Dev/cfurst/log options (#17)
Browse files Browse the repository at this point in the history
*  bad attempt at dynamic log redirect.

*  environment variable logging solution
  • Loading branch information
Skr00b@!! authored Apr 23, 2019
1 parent 0910af1 commit 4090dd8
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
15 changes: 9 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,21 @@ This is currently BETA. Please report any issues.
$ cd /path/to/clone/of/fintojs
## simple start - output to console:
$ sudo npm start
## with a log
$ sudo npm start > /path/to/log/file 2>&1
## with a log - all output will be appended to the logfile
$ FINTOJS_LOG_PATH=/absolute/path/to/log-file sudo -E npm start
## with a log - forking server to background
$ sudo npm start > /path/to/log/file 2>&1 &
## note: the above will start the server if you have already authenticated with a previous sudo command. If not, it will pause, waiting for your to enter your password. You might want to start this without the bg symbol '&', enter your password and then background it after the server has started.
## without a log
$ sudo npm start
$ FINTOJS_LOG_PATH=/absolute/path/to/log-file sudo -E npm start &
## note on the above two examples: FINTOJS_LOG_PATH is an environment variable you can set through all the usual channels (export, .profile, .bash_profile etc) BUT
## you MUST use the -E option with sudo to inherit your current environment
## without sudo you would need to customize at least the port:
$ npm start -- -p 8080 # note the '--' it's necessary!
```
This should work with all the helpers. Please report any issues or missing features (except the logging, of course).

### LOGGING

To log your server output it's best to set the `FINTOJS_LOG_PATH` environment variable. If you set this to the absolute path of your log file, you will have all output appended to that file and you can start your server in the background. This is achieved through shell redirection rather than using a logging library. If you are planing on starting your server with elevated privileges, you will need to have `sudo` inherit your environment which you can do with the `-E` option as noted in the SYNOPSIS section above.

### TESTING

We have a test script you can use to test your server (**on port 80 only!**) with any credentials you have. This is a good way to test to see if your configuration is working, if the server is up, etc:
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
"main": "finto.js",
"scripts": {
"test": "node test/ServerTest.js",
"install-fintorc": "node test/InstallFintorc.js"
"install-fintorc": "node test/InstallFintorc.js",
"start": "if [ ! -z \"$FINTOJS_LOG_PATH\" ]; then node server.js >> $FINTOJS_LOG_PATH; else node server.js; fi"
},
"dependencies": {
"envious": "0.2.*",
Expand Down

0 comments on commit 4090dd8

Please sign in to comment.