summary refs log tree commit diff
path: root/host/Spacebar-nginx/containers/spacebar-server-dev-nix/services
diff options
context:
space:
mode:
Diffstat (limited to 'host/Spacebar-nginx/containers/spacebar-server-dev-nix/services')
-rw-r--r--host/Spacebar-nginx/containers/spacebar-server-dev-nix/services/postgres.nix2
-rwxr-xr-xhost/Spacebar-nginx/containers/spacebar-server-dev-nix/services/spacebar-server.nix42
2 files changed, 37 insertions, 7 deletions
diff --git a/host/Spacebar-nginx/containers/spacebar-server-dev-nix/services/postgres.nix b/host/Spacebar-nginx/containers/spacebar-server-dev-nix/services/postgres.nix
index 97ea3e6..b3c8cad 100644
--- a/host/Spacebar-nginx/containers/spacebar-server-dev-nix/services/postgres.nix
+++ b/host/Spacebar-nginx/containers/spacebar-server-dev-nix/services/postgres.nix
@@ -16,7 +16,7 @@
     '';
     initialScript = pkgs.writeText "backend-initScript" ''
       CREATE ROLE spacebar WITH LOGIN PASSWORD 'spacebar' CREATEDB;
-      CREATE DATABASE spacebar;
+      CREATE DATABASE spacebar WITH OWNER spacebar ENCODING 'UTF8';
       GRANT ALL PRIVILEGES ON DATABASE spacebar TO spacebar;
     '';
     #dataDir = "/data/pg";
diff --git a/host/Spacebar-nginx/containers/spacebar-server-dev-nix/services/spacebar-server.nix b/host/Spacebar-nginx/containers/spacebar-server-dev-nix/services/spacebar-server.nix
index d207687..1debbbd 100755
--- a/host/Spacebar-nginx/containers/spacebar-server-dev-nix/services/spacebar-server.nix
+++ b/host/Spacebar-nginx/containers/spacebar-server-dev-nix/services/spacebar-server.nix
@@ -1,41 +1,71 @@
 { config, pkgs, lib, spacebar-server, ... }:
 
 {
+  services.rabbitmq.enable = true;
+
+  systemd.tmpfiles.rules = [  "d /var/lib/spacebar-server 0750 spacebar spacebar" ];
+  users.users.spacebar = {
+    isSystemUser = true;
+    group = "spacebar";
+    home = "/var/lib/spacebar-server";
+    createHome = true;
+    shell = "/bin/false";
+  };
+
+  users.groups.spacebar = {
+    #isSystemGroup = true;
+  };
+
   systemd.services = {
     "spacebar-server-api" = {
         wantedBy = [ "multi-user.target" ];
-        after = [ "resolvconf.target" ];
+        after = [ "resolvconf.target" "postgresql.service" "rabbitmq.service" ];
         serviceConfig = {
             ExecStart = ''
               ${spacebar-server.packages.${pkgs.system}.default}/bin/start-api
               '';
             #Restart = "never";
-            User = "root";
+            User = "spacebar";
             WorkingDirectory = "/var/lib/spacebar-server";
+            Environment = [
+              "DATABASE=postgres://spacebar:spacebar@127.0.0.1/spacebar"
+              "LOG_REQUESTS='-'"
+              #"DB_LOGGING='true'"
+            ];
         };
     };
     "spacebar-server-gateway" = {
         wantedBy = [ "multi-user.target" ];
-        after = [ "resolvconf.target" ];
+        after = [ "resolvconf.target" "postgresql.service" "rabbitmq.service" "spacebar-server-api.service" ];
         serviceConfig = {
             ExecStart = ''
               ${spacebar-server.packages.${pkgs.system}.default}/bin/start-gateway
               '';
             #Restart = "never";
-            User = "root";
+            User = "spacebar";
             WorkingDirectory = "/var/lib/spacebar-server";
+            Environment = [
+              "DATABASE=postgres://spacebar:spacebar@127.0.0.1/spacebar"
+              "LOG_REQUESTS='-'"
+              #"DB_LOGGING='true'"
+            ];
         };
     };
     "spacebar-server-cdn" = {
         wantedBy = [ "multi-user.target" ];
-        after = [ "resolvconf.target" ];
+        after = [ "resolvconf.target" "postgresql.service" "rabbitmq.service" "spacebar-server-api.service" ];
         serviceConfig = {
             ExecStart = ''
               ${spacebar-server.packages.${pkgs.system}.default}/bin/start-cdn
               '';
             #Restart = "never";
-            User = "root";
+            User = "spacebar";
             WorkingDirectory = "/var/lib/spacebar-server";
+            Environment = [
+              "DATABASE=postgres://spacebar:spacebar@127.0.0.1/spacebar"
+              "LOG_REQUESTS='-'"
+              #"DB_LOGGING='true'"
+            ];
         };
     };
   };