summaryrefslogtreecommitdiff
path: root/src/Propellor/Property/Uwsgi.hs
diff options
context:
space:
mode:
authorSean Whitton <spwhitton@spwhitton.name>2016-06-10 15:21:47 +0900
committerSean Whitton <spwhitton@spwhitton.name>2016-06-10 15:21:47 +0900
commit19b3eb8ff90092748d8718d751d5fd6865b6e7cd (patch)
tree466321e4bf273a01439adda82de94f070b1c329d /src/Propellor/Property/Uwsgi.hs
parentde50503e4dbdea853e899f01e8828cf4f454dd57 (diff)
parent2cdc8a2eb9a3cf87c3f5ac09ee8c00931a666997 (diff)
Record propellor (3.0.5-1) in archive suite sid
Diffstat (limited to 'src/Propellor/Property/Uwsgi.hs')
-rw-r--r--src/Propellor/Property/Uwsgi.hs49
1 files changed, 49 insertions, 0 deletions
diff --git a/src/Propellor/Property/Uwsgi.hs b/src/Propellor/Property/Uwsgi.hs
new file mode 100644
index 00000000..4eb94103
--- /dev/null
+++ b/src/Propellor/Property/Uwsgi.hs
@@ -0,0 +1,49 @@
+-- | Maintainer: FĂ©lix Sipma <felix+propellor@gueux.org>
+
+module Propellor.Property.Uwsgi where
+
+import Propellor.Base
+import qualified Propellor.Property.File as File
+import qualified Propellor.Property.Apt as Apt
+import qualified Propellor.Property.Service as Service
+
+type ConfigFile = [String]
+
+type AppName = String
+
+appEnabled :: AppName -> ConfigFile -> RevertableProperty DebianLike DebianLike
+appEnabled an cf = enable <!> disable
+ where
+ enable = appVal an `File.isSymlinkedTo` appValRelativeCfg an
+ `describe` ("uwsgi app enabled " ++ an)
+ `requires` appAvailable an cf
+ `requires` installed
+ `onChange` reloaded
+ disable = File.notPresent (appVal an)
+ `describe` ("uwsgi app disable" ++ an)
+ `requires` installed
+ `onChange` reloaded
+
+appAvailable :: AppName -> ConfigFile -> Property DebianLike
+appAvailable an cf = ("uwsgi app available " ++ an) ==>
+ tightenTargets (appCfg an `File.hasContent` (comment : cf))
+ where
+ comment = "# deployed with propellor, do not modify"
+
+appCfg :: AppName -> FilePath
+appCfg an = "/etc/uwsgi/apps-available" </> an <.> "ini"
+
+appVal :: AppName -> FilePath
+appVal an = "/etc/uwsgi/apps-enabled/" </> an <.> "ini"
+
+appValRelativeCfg :: AppName -> File.LinkTarget
+appValRelativeCfg an = File.LinkTarget $ "../apps-available" </> an <.> "ini"
+
+installed :: Property DebianLike
+installed = Apt.installed ["uwsgi"]
+
+restarted :: Property DebianLike
+restarted = Service.restarted "uwsgi"
+
+reloaded :: Property DebianLike
+reloaded = Service.reloaded "uwsgi"