diff options
author | Joey Hess <joeyh@joeyh.name> | 2017-05-09 16:27:45 -0400 |
---|---|---|
committer | Joey Hess <joeyh@joeyh.name> | 2017-05-09 16:27:45 -0400 |
commit | 54182fd08797eb82fe39dd67b7b5039aaa1dc0a1 (patch) | |
tree | 689c05251341632ce8a895a50231b3e00e63094a | |
parent | 0bf26b8e905e2685c92e8eef4d9cdd9fcf5c49c4 (diff) | |
download | debug-me-54182fd08797eb82fe39dd67b7b5039aaa1dc0a1.tar.gz |
Server: DEBUG_ME_FROM_EMAIL can be used to specify the --from-email.
This is used in debug-me.default to encourage configuring it.
-rw-r--r-- | CHANGELOG | 4 | ||||
-rw-r--r-- | Server.hs | 11 | ||||
-rw-r--r-- | debug-me.1 | 2 | ||||
-rw-r--r-- | debug-me.default | 6 |
4 files changed, 19 insertions, 4 deletions
@@ -2,8 +2,8 @@ debug-me (1.20170506) UNRELEASED; urgency=medium * Server: Use "postmaster" as default --from-email address rather than "unknown@server". - * debug-me.default: Include a --from-email setting, - to encourage it be configured. + * Server: DEBUG_ME_FROM_EMAIL can be used to specify the --from-email. + This is used in debug-me.default to encourage configuring it. Thanks, Sean Whitton. * Avoid crash when --use-server is given an url that does not include a path. @@ -33,6 +33,7 @@ import System.IO import System.Directory import System.Mem.Weak import Network.Mail.Mime +import System.Environment type ServerState = M.Map SessionID Session @@ -95,7 +96,9 @@ closeSession :: Session -> STM () closeSession (Session bchan _ _) = closeTMChan bchan server :: ServerOpts -> IO () -server o = runSettings settings . app o =<< newServerState +server o = do + o' <- checkEnv o + runSettings settings . app o' =<< newServerState where settings = -- Prefer IPv6 but allow IPv4 as well @@ -105,6 +108,12 @@ server o = runSettings settings . app o =<< newServerState setPort (serverPort o) $ defaultSettings +checkEnv :: ServerOpts -> IO ServerOpts +checkEnv o = go <$> lookupEnv "DEBUG_ME_FROM_EMAIL" + where + go Nothing = o + go (Just email) = o { serverEmail = Just (T.pack email) } + app :: ServerOpts -> TVar ServerState -> Application app o ssv = websocketsOr connectionOptions (websocketApp o ssv) webapp where @@ -88,6 +88,8 @@ Specify a port for the debug-me server to listen to. .IP "--from-email address" The server will email session logs to users. It's a good idea to provide a real email address, otherwise a dummy one will be used. +You can also set the enviroment variable DEBUG_ME_FROM_EMAIL to configure +this. .IP "--delete-old-logs" Normally the server will retain old log files so that users and developers can refer to them. This option makes it delete the log file once the diff --git a/debug-me.default b/debug-me.default index dded3e5..219b318 100644 --- a/debug-me.default +++ b/debug-me.default @@ -1,2 +1,6 @@ +# Configure the email address that debug-me uses when emailing logs to +# users. +DEBUG_ME_FROM_EMAIL=postmaster + # Parameters to pass to debug-me when it's started as a daemon. -DAEMON_PARAMS="--server /var/log/debug-me/ --delete-old-logs --from-email postmaster" +DAEMON_PARAMS="--server /var/log/debug-me/ --delete-old-logs" |