Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: keep same port after stopping and restarting #45

Merged
merged 1 commit into from
Jan 13, 2025
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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,10 @@
"extract-zip": "^2.0.1",
"find-cache-dir": "^3.3.2",
"find-package-json": "^1.2.0",
"get-port": "^5.1.1",
"https-proxy-agent": "^7.0.0",
"lockfile": "^1.0.4",
"lodash.defaultsdeep": "^4.6.1",
"portfinder": "^1.0.32",
"rimraf": "^5.0.1",
"semver": "^7.5.3",
"tar": "^6.1.15",
Expand Down
2 changes: 1 addition & 1 deletion src/RedisMemoryServer.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ChildProcess } from 'child_process';
import * as tmp from 'tmp';
import getPort from 'get-port';
import { getPortPromise as getPort } from 'portfinder';
import { isNullOrUndefined } from './util/db_util';
import RedisInstance from './util/RedisInstance';
import { RedisBinaryOpts } from './util/RedisBinary';
Expand Down
6 changes: 6 additions & 0 deletions src/__tests__/singleDB-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,10 @@ describe('Single redisServer', () => {
'Redis instance already in status startup/running/error. Use debug for more info.'
);
});

it('should keep the same port after stopping and restarting', async () => {
await redisServer.stop();
await redisServer.start();
expect(await con.ping()).toBe('PONG');
});
});
53 changes: 43 additions & 10 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1864,6 +1864,15 @@ __metadata:
languageName: node
linkType: hard

"async@npm:^2.6.4":
version: 2.6.4
resolution: "async@npm:2.6.4"
dependencies:
lodash: "npm:^4.17.14"
checksum: 0ebb3273ef96513389520adc88e0d3c45e523d03653cc9b66f5c46f4239444294899bfd13d2b569e7dbfde7da2235c35cf5fd3ece9524f935d41bbe4efccdad0
languageName: node
linkType: hard

"babel-jest@npm:^29.6.0":
version: 29.6.0
resolution: "babel-jest@npm:29.6.0"
Expand Down Expand Up @@ -2640,6 +2649,15 @@ __metadata:
languageName: node
linkType: hard

"debug@npm:^3.2.7":
version: 3.2.7
resolution: "debug@npm:3.2.7"
dependencies:
ms: "npm:^2.1.1"
checksum: 37d96ae42cbc71c14844d2ae3ba55adf462ec89fd3a999459dec3833944cd999af6007ff29c780f1c61153bcaaf2c842d1e4ce1ec621e4fc4923244942e4a02a
languageName: node
linkType: hard

"decamelize-keys@npm:^1.1.0":
version: 1.1.1
resolution: "decamelize-keys@npm:1.1.1"
Expand Down Expand Up @@ -3400,13 +3418,6 @@ __metadata:
languageName: node
linkType: hard

"get-port@npm:^5.1.1":
version: 5.1.1
resolution: "get-port@npm:5.1.1"
checksum: 2873877a469b24e6d5e0be490724a17edb39fafc795d1d662e7bea951ca649713b4a50117a473f9d162312cb0e946597bd0e049ed2f866e79e576e8e213d3d1c
languageName: node
linkType: hard

"get-stream@npm:^5.1.0":
version: 5.2.0
resolution: "get-stream@npm:5.2.0"
Expand Down Expand Up @@ -4820,7 +4831,7 @@ __metadata:
languageName: node
linkType: hard

"lodash@npm:^4.17.15":
"lodash@npm:^4.17.14, lodash@npm:^4.17.15":
version: 4.17.21
resolution: "lodash@npm:4.17.21"
checksum: d8cbea072bb08655bb4c989da418994b073a608dffa608b09ac04b43a791b12aeae7cd7ad919aa4c925f33b48490b5cfe6c1f71d827956071dae2e7bb3a6b74c
Expand Down Expand Up @@ -5124,6 +5135,17 @@ __metadata:
languageName: node
linkType: hard

"mkdirp@npm:^0.5.6":
version: 0.5.6
resolution: "mkdirp@npm:0.5.6"
dependencies:
minimist: "npm:^1.2.6"
bin:
mkdirp: bin/cmd.js
checksum: e2e2be789218807b58abced04e7b49851d9e46e88a2f9539242cc8a92c9b5c3a0b9bab360bd3014e02a140fc4fbc58e31176c408b493f8a2a6f4986bd7527b01
languageName: node
linkType: hard

"mkdirp@npm:^1.0.3":
version: 1.0.4
resolution: "mkdirp@npm:1.0.4"
Expand All @@ -5147,7 +5169,7 @@ __metadata:
languageName: node
linkType: hard

"ms@npm:^2.0.0":
"ms@npm:^2.0.0, ms@npm:^2.1.1":
version: 2.1.3
resolution: "ms@npm:2.1.3"
checksum: d924b57e7312b3b63ad21fc5b3dc0af5e78d61a1fc7cfb5457edaf26326bf62be5307cc87ffb6862ef1c2b33b0233cdb5d4f01c4c958cc0d660948b65a287a48
Expand Down Expand Up @@ -5582,6 +5604,17 @@ __metadata:
languageName: node
linkType: hard

"portfinder@npm:^1.0.32":
version: 1.0.32
resolution: "portfinder@npm:1.0.32"
dependencies:
async: "npm:^2.6.4"
debug: "npm:^3.2.7"
mkdirp: "npm:^0.5.6"
checksum: cef8b567b78aabccc59fe8e103bac8b394bb45a6a69be626608f099f454124c775aaf47b274c006332c07ab3f501cde55e49aaeb9d49d78d90362d776a565cbf
languageName: node
linkType: hard

"prelude-ls@npm:^1.2.1":
version: 1.2.1
resolution: "prelude-ls@npm:1.2.1"
Expand Down Expand Up @@ -5817,14 +5850,14 @@ __metadata:
extract-zip: "npm:^2.0.1"
find-cache-dir: "npm:^3.3.2"
find-package-json: "npm:^1.2.0"
get-port: "npm:^5.1.1"
https-proxy-agent: "npm:^7.0.0"
husky: "npm:^8.0.3"
ioredis: "npm:^5.3.2"
jest: "npm:^29.6.0"
lint-staged: "npm:^13.2.3"
lockfile: "npm:^1.0.4"
lodash.defaultsdeep: "npm:^4.6.1"
portfinder: "npm:^1.0.32"
prettier: "npm:^2.8.8"
rimraf: "npm:^5.0.1"
semver: "npm:^7.5.3"
Expand Down
Loading