fix: restart after re-writing config file with SSL certificate

This commit is contained in:
Mahdi Dibaiee 2017-02-19 14:16:30 +03:30
parent cd44b525d1
commit 96d5eee027

View File

@ -32,18 +32,9 @@ module System.Serverman.Actions.Nginx (nginx) where
writeFile path content writeFile path content
putStrLn $ "wrote your configuration file to " ++ path 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 when (ssl params) $ do
case serverType params of case serverType params of
Static -> do Static -> do
@ -56,6 +47,7 @@ module System.Serverman.Actions.Nginx (nginx) where
Right _ -> do Right _ -> do
putStrLn $ "created a certificate for " ++ domain params putStrLn $ "created a certificate for " ++ domain params
writeFile path (show params) writeFile path (show params)
wait =<< restart
wait letsencrypt wait letsencrypt
_ -> do _ -> do
@ -66,3 +58,13 @@ module System.Serverman.Actions.Nginx (nginx) where
putStrLn $ "for more information, see: https://certbot.eff.org/" putStrLn $ "for more information, see: https://certbot.eff.org/"
return () 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)