Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ program
const spinner = ora(`Starting instance '${name}'...`).start();

try {
await instanceManager.startInstance(name);
await instanceManager.startInstanceWithService(name);
spinner.succeed(`Instance '${name}' started successfully`);

const config = await instanceManager.getInstanceStatus(name);
Expand All @@ -154,7 +154,7 @@ program
const spinner = ora(`Stopping instance '${name}'...`).start();

try {
await instanceManager.stopInstance(name);
await instanceManager.stopInstanceWithService(name);
spinner.succeed(`Instance '${name}' stopped successfully`);

} catch (error) {
Expand Down
4 changes: 2 additions & 2 deletions src/instance/manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,12 +150,12 @@ export class InstanceManager {
}

if (config.status?.state === 'running') {
await this.stopInstance(name);
await this.stopInstanceWithService(name);
// Wait a moment for cleanup
await new Promise(resolve => setTimeout(resolve, 2000));
}

await this.startInstance(name);
await this.startInstanceWithService(name);
}

async getInstanceStatus(name: string): Promise<PostgreSQLInstanceConfig | null> {
Expand Down
11 changes: 8 additions & 3 deletions src/service/manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -205,20 +205,25 @@ export class ServiceManager {
const restartSec = config.spec.service?.restartSec || 5;
const user = useUserService ? process.env.USER || 'postgres' : 'postgres';

// Generate socket directory path from data directory
const socketDir = join(config.spec.storage.dataDirectory, 'sockets');

return `[Unit]
Description=PostgreSQL database server for ${config.metadata.name}
Documentation=man:postgres(1)
After=network.target
Wants=network.target

[Service]
Type=forking
Type=notify
User=${user}
ExecStart=${postgresPath} -D ${config.spec.storage.dataDirectory}
ExecStart=${postgresPath} -D ${config.spec.storage.dataDirectory} -k ${socketDir} -p ${config.spec.network.port}
ExecReload=/bin/kill -HUP $MAINPID
ExecStop=/bin/kill -TERM $MAINPID
KillMode=mixed
KillSignal=SIGINT
TimeoutSec=0
TimeoutSec=120
TimeoutStopSec=120

# Restart policy
Restart=${restartPolicy}
Expand Down