From 96d5eee0274c20ccf7e5741ff844fc4396693a61 Mon Sep 17 00:00:00 2001 From: Mahdi Dibaiee Date: Sun, 19 Feb 2017 14:16:30 +0330 Subject: [PATCH] fix: restart after re-writing config file with SSL certificate --- src/System/Serverman/Actions/Nginx.hs | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/src/System/Serverman/Actions/Nginx.hs b/src/System/Serverman/Actions/Nginx.hs index fa70306..f68dbca 100644 --- a/src/System/Serverman/Actions/Nginx.hs +++ b/src/System/Serverman/Actions/Nginx.hs @@ -32,18 +32,9 @@ module System.Serverman.Actions.Nginx (nginx) where writeFile path content putStrLn $ "wrote your configuration file to " ++ path - - restart <- async $ do - let command = "systemctl restart nginx" - result <- tryIOError $ callCommand command - case result of - Left err -> do - putStrLn $ commandError command - Right _ -> - putStrLn $ "restarted " ++ show (service params) - - wait restart + wait =<< restart + when (ssl params) $ do case serverType params of Static -> do @@ -56,6 +47,7 @@ module System.Serverman.Actions.Nginx (nginx) where Right _ -> do putStrLn $ "created a certificate for " ++ domain params writeFile path (show params) + wait =<< restart wait letsencrypt _ -> do @@ -66,3 +58,13 @@ module System.Serverman.Actions.Nginx (nginx) where putStrLn $ "for more information, see: https://certbot.eff.org/" return () + where + restart = async $ do + let command = "systemctl restart nginx" + result <- tryIOError $ callCommand command + case result of + Left err -> do + putStrLn $ commandError command + Right _ -> + putStrLn $ "restarted " ++ show (service params) +