@sysnee/pgs 0.1.7-rc.1 → 0.1.7-rc.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/manager.js +14 -2
  2. package/package.json +1 -1
package/manager.js CHANGED
@@ -19,6 +19,7 @@ const CONFIG_DIR = path.join(os.homedir(), '.sysnee-config');
19
19
 
20
20
  const COMPOSE_FILE_PATH = path.join(CONFIG_DIR, 'docker-compose.yml');
21
21
  const INIT_DIR_PATH = path.join(CONFIG_DIR, 'init');
22
+ const LUA_DIR_PATH = path.join(CONFIG_DIR, 'haproxy-lua');
22
23
  const HAPROXY_CFG_PATH = path.join(CONFIG_DIR, 'haproxy.cfg');
23
24
  const TENANT_ACCESS_FILE_PATH = path.join(CONFIG_DIR, 'tenant-access.json');
24
25
  const SETUP_STATUS_PATH = path.join(CONFIG_DIR, 'status.txt');
@@ -119,7 +120,7 @@ function updateHAProxyDependsOn() {
119
120
  ports: ['5432:5432'],
120
121
  volumes: [
121
122
  `${HAPROXY_CFG_PATH}:/usr/local/etc/haproxy/haproxy.cfg:ro`,
122
- './haproxy-lua:/etc/haproxy/lua:ro',
123
+ `${LUA_DIR_PATH}:/etc/haproxy/lua:ro`,
123
124
  `${TENANT_ACCESS_FILE_PATH}:/etc/haproxy/tenant-access.json:ro`
124
125
  ],
125
126
  networks: ['postgres_network'],
@@ -137,7 +138,7 @@ function updateHAProxyDependsOn() {
137
138
  saveCompose(doc);
138
139
 
139
140
  // Restart HAProxy
140
- executeCommand('docker restart postgres_proxy');
141
+ executeCommand('docker compose up -d haproxy');
141
142
  }
142
143
 
143
144
  function createInitScript({ tenantId, password, databaseName }) {
@@ -232,6 +233,17 @@ function createInitialFiles() {
232
233
  const haproxyTemplate = readFileSync(path.join(__dirname, 'haproxy.cfg'), 'utf8');
233
234
  writeFileSync(HAPROXY_CFG_PATH, haproxyTemplate);
234
235
  }
236
+
237
+ // Lua
238
+ if (!existsSync(LUA_DIR_PATH)) {
239
+ mkdirSync(LUA_DIR_PATH, { recursive: true });
240
+ }
241
+ const luaSourceFile = path.join(__dirname, 'haproxy-lua', 'pg-route.lua');
242
+ const luaDestFile = path.join(LUA_DIR_PATH, 'pg-route.lua');
243
+ if (!existsSync(luaDestFile)) {
244
+ const luaContent = readFileSync(luaSourceFile, 'utf8');
245
+ writeFileSync(luaDestFile, luaContent);
246
+ }
235
247
  }
236
248
 
237
249
  function checkSetupStatus() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sysnee/pgs",
3
- "version": "0.1.7-rc.1",
3
+ "version": "0.1.7-rc.2",
4
4
  "description": "Dynamic PostgreSQL service instance manager",
5
5
  "type": "module",
6
6
  "bin": {