works:programmer:other:mongo-ctrl
Mongo Service Control
Данный скрипт я написал для управления сервисом MongoDB по OS Windows, самые полезные функции в нём в принцепе есть.
- ctrl.cmd
@echo off set MONGOD_PATH="C:\Program Files\MongoDB\Server\3.6\bin\" set DATA_PATH="C:\Bin\MongoData" set SERVICE=mongodb IF "%1"=="install" goto install IF "%1"=="remove" goto remove IF "%1"=="start" goto start IF "%1"=="stop" goto stop IF "%1"=="status" goto status goto help :install %MONGOD_PATH%\mongod.exe --serviceName %SERVICE% --install --port 27017 --auth ^ --bind_ip_all --dbpath %DATA_PATH%\DB --sslMode requireSSL ^ --logpath %DATA_PATH%\Logs\general.log --logappend ^ --sslPEMKeyFile %DATA_PATH%\CertVault\mongodb.pem goto exit :remove %MONGOD_PATH%\mongod.exe --serviceName %SERVICE% --remove goto exit :start net start %SERVICE% goto exit :stop net stop %SERVICE% goto exit :status for /F "tokens=3 delims=: " %%H in ('sc query "%SERVICE%" ^| findstr "STATE"') do ( if /I "%%H" EQU "RUNNING" ( echo State of %SERVICE% is RUNNING goto exit ) if /I "%%H" NEQ "RUNNING" ( echo State of %SERVICE% is STOPPED ) ) goto exit :help echo Simple help for this file echo %0 {install^|start^|stop^|remove^|status} echo install - configure and install daemon service echo start - start daemon echo stop - stop daemon echo remove - remove daemon service echo status - get service status :exit
works/programmer/other/mongo-ctrl.txt · Последнее изменение: 2018/12/15 17:18 — 127.0.0.1