Skip to content

Commit 4090dd8

Browse files
author
Skr00b@!!
authored
Dev/cfurst/log options (#17)
* bad attempt at dynamic log redirect. * environment variable logging solution
1 parent 0910af1 commit 4090dd8

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

README.md

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,21 @@ This is currently BETA. Please report any issues.
2020
$ cd /path/to/clone/of/fintojs
2121
## simple start - output to console:
2222
$ sudo npm start
23-
## with a log
24-
$ sudo npm start > /path/to/log/file 2>&1
23+
## with a log - all output will be appended to the logfile
24+
$ FINTOJS_LOG_PATH=/absolute/path/to/log-file sudo -E npm start
2525
## with a log - forking server to background
26-
$ sudo npm start > /path/to/log/file 2>&1 &
27-
## 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.
28-
## without a log
29-
$ sudo npm start
26+
$ FINTOJS_LOG_PATH=/absolute/path/to/log-file sudo -E npm start &
27+
## 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
28+
## you MUST use the -E option with sudo to inherit your current environment
3029
## without sudo you would need to customize at least the port:
3130
$ npm start -- -p 8080 # note the '--' it's necessary!
3231
```
3332
This should work with all the helpers. Please report any issues or missing features (except the logging, of course).
3433

34+
### LOGGING
35+
36+
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.
37+
3538
### TESTING
3639

3740
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:

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
"main": "finto.js",
66
"scripts": {
77
"test": "node test/ServerTest.js",
8-
"install-fintorc": "node test/InstallFintorc.js"
8+
"install-fintorc": "node test/InstallFintorc.js",
9+
"start": "if [ ! -z \"$FINTOJS_LOG_PATH\" ]; then node server.js >> $FINTOJS_LOG_PATH; else node server.js; fi"
910
},
1011
"dependencies": {
1112
"envious": "0.2.*",

0 commit comments

Comments
 (0)