Visual Studio CodeからMongoDBのようなバックグラウンドサービスを実行したいと考えています。 Visual Studioでバックグラウンドサービスを実行するコード
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "0.1.0",
"command": "mongod",
"isShellCommand": false,
"args": ["--dbpath", "data\\db"],
"showOutput": "always"
}
しかし、これは、例えば、サーバーを停止する制御なしでVS内でそれを実行します:私はこのようなタスクランナーを通してそれを実行しようとしましたCtrl + Cを押してください。
普通の方法は、cmd.exeを実行してそこからmongodコマンドを実行することです。しかし、私はそれをVSにうまく組み込むことが大好きです。 beginsPatternとendsPatternがウォッチャータスクの開始と終了のコンソール出力を定義見
{
"version": "0.1.0",
"command": "npm",
"isShellCommand": true,
"echoCommand": false,
"suppressTaskName": true,
"showOutput": "always",
"tasks": [
{
"args": [
"run",
"start",
"--silent"
],
"problemMatcher": [
{
"owner": "custom",
"pattern": [],
"watching": {
"activeOnStart": true,
"beginsPattern": "webpack: bundle is now INVALID",
"endsPattern": "webpack: bundle is now VALID"
}
}
],
"isWatching": true,
"taskName": "development"
}
]
}
(オプション)問題のMatcher:これは例をWebPACKの中のような
申し訳ありませんが、これで問題は解決しません。私はまだプロセスを適切に制御することができないからです。このタスクを終了すると、ctrl + Cのようなシグナルで適切にシャットダウンするのではなく、mongoプロセスだけが終了します。 – totkeks