Why no postgresql service after installation? - windows

I installed postgres via the Windows installer postgresql-14.5-1-windows-x64.exe ,check the service if it is in my windows10.
Show with cmd way:
C:\Windows\system32>sc queryex type=service state=all | find /i "postgresql"
C:\Windows\system32>sc queryex type=service state=all | find /i "postgresql*"
Nothing get.
Show with gui way:
Why no postgresql service after installation?

Related

Windows Server 2016 Docker image support for SQL Server?

I've taken note of various Dockerfiles for SQL Server support, most recently: https://blogs.msdn.microsoft.com/sqlserverstorageengine/2016/03/21/sql-server-in-windows-containers/
And, I've seen the SQL Server Image support provided by WinDocks on Windows Server 2012 but I haven't seen whether Microsoft has announced plans to support SQL Server 2016 with Docker image support on Windows Server 2016? And, if so, has anyone heard if MS plans to include support in dockerfile support for adding or mounting databases in containers? Thanks in advance!
UPDATE: The SQL Server team now maintains a 2014 Express image on Docker Hub: https://hub.docker.com/r/microsoft/mssql-server-2014-express-windows/
SQL Server 2016 is currently a little harder to install, but 2014 works fine. Here's my (slightly hacky) Dockerfile:
FROM microsoft/dotnet35
ENV SQL_EXPRESS_DOWNLOAD_URL "https://download.microsoft.com/download/1/5/6/156992E6-F7C7-4E55-833D-249BD2348138/ENU/x64/SQLEXPR_x64_ENU.exe"
ENV SQL_SERVER_SA_PASSWORD "Password1"
WORKDIR /
RUN powershell -Command (New-Object System.Net.WebClient).DownloadFile('%SQL_EXPRESS_DOWNLOAD_URL%', 'sqlexpress.exe')
RUN /sqlexpress.exe /qs /x:setup && /setup/setup.exe /q /ACTION=Install /INSTANCENAME=SQLEXPRESS /FEATURES=SQLEngine /UPDATEENABLED=0 /SECURITYMODE=SQL /SAPWD=%SQL_SERVER_SA_PASSWORD% /SQLSVCACCOUNT="NT AUTHORITY\System" /SQLSYSADMINACCOUNTS="BUILTIN\ADMINISTRATORS" /TCPENABLED=1 /NPENABLED=0 /IACCEPTSQLSERVERLICENSETERMS && del /F /Q sqlexpress.exe && rd /q /s setup
RUN powershell -Command \
set-strictmode -version latest ; \
stop-service MSSQL`$SQLEXPRESS ; \
set-itemproperty -path 'HKLM:\software\microsoft\microsoft sql server\mssql12.SQLEXPRESS\mssqlserver\supersocketnetlib\tcp\ipall' -name tcpdynamicports -value '' ; \
set-itemproperty -path 'HKLM:\software\microsoft\microsoft sql server\mssql12.SQLEXPRESS\mssqlserver\supersocketnetlib\tcp\ipall' -name tcpport -value 1433 ; \
start-service MSSQL`$SQLEXPRESS
CMD powershell -Command while ($true) { Start-Sleep -Seconds 3600 }
EXPOSE 1433
It's based on this one: https://github.com/brogersyh/Dockerfiles-for-windows/blob/master/sqlexpress/dockerfile
Follow up on this, Microsoft released Windows Server core 1709 with support for network attached SMB shares. I also note that Windocks has released Docker SQL Server container database cloning support, which I've tested using Core 1709,and can now service a team with 500 GB data images in roughly 1 minute. You can see more on Windocks at https://windocks.com/docker-sql-server-containers
If you want to install a full version of sql server (not only the Express version), here's how you can do it: https://github.com/mabead/Docker.SqlServer

script to check if windows service is running and if it ain't to start that service. Windows 2000

Unfortunately the SC command isn't available on W2000 yet, so I cannot use it.
I'm trying to check if a service is running or not on a W2000 server, and if it is not running the script should be able to start the service.
How to do this on Windows 2000?
net start | find "yourservice"
if %errorlevel%==1 net start "yourservice"

Add nginx.exe as Windows system service (like Apache)?

I set up NGINX as a front end server for static content and I use Apache as a back-end server for other thing.
The thing is I can't find a logical answer that allows me to make nginx.exe a Windows system service (like my Apache).
Any come across an answer to this?
How to do it with Windows Service Wrapper
(Note: There are easier alternatives by now - see also solutions described here below using chocolatey package manager by suneg and using NSSM directly from Adamy)
Download the latest version of Windows Service Wrapper via github or nuget.
Current version as of this writing is v2.2.0
Since v2.x executables for .NET2.0 and .NET4.0 are available - others only on demand.
Rename winsw-*.exe to something like nginxservice.exe.
This is the name that will show up for the process that owns your nginx process.
Place an XML file next to the exe with the same base name, e.g. nginxservice.xml. The contents should be like below (verify your nginx location).
<service>
<id>nginx</id>
<name>nginx</name>
<description>nginx</description>
<executable>c:\nginx\nginx.exe</executable>
<logpath>c:\nginx\</logpath>
<logmode>roll</logmode>
<depend></depend>
<startargument>-p</startargument>
<startargument>c:\nginx</startargument>
<stopexecutable>c:\nginx\nginx.exe</stopexecutable>
<stopargument>-p</stopargument>
<stopargument>c:\nginx</stopargument>
<stopargument>-s</stopargument>
<stopargument>stop</stopargument>
</service>
You can find up to date details about the configuration on the config github page, a generic example showing all possible options here and an installation guide.
Run the command nginxservice.exe install as administrator.
You will now have an nginx service in your Services! (It is set to start automatically on boot; if you want to start your server, you must manually start the service (net start nginx).)
Detailed description of correctly setting up nginx as a Windows Service:
http://web.archive.org/web/20150819035021/http://misterdai.yougeezer.co.uk/posts/2009/10/16/nginx-windows-service/
Additional info not contained in above blog post:
You can find the latest version of the Windows Service Wrapper also via this Maven Repository:
http://repo.jenkins-ci.org
Examples for Maven + Gradle:
<dependency>
<groupId>com.sun.winsw</groupId>
<artifactId>winsw</artifactId>
<version>2.2.0</version>
<classifier>bin</classifier>
<packaging>exe</packaging>
</dependency>
<repository>
<id>jenkinsci</id>
<name>jenkinsci-releases</name>
<url>http://repo.jenkins-ci.org/releases</url>
</repository>
compile "com.sun.winsw:winsw:2.2.0"
repositories {
mavenCentral()
maven { url http://repo.jenkins-ci.org/releases }
}
Download NSSM form
http://nssm.cc/download .
"Run %NSSM_HOME%\nssm.exe install “Nginx”"
Select the Nginx executable in the NSSM dialog, then OK.
Go to Services and start the new created service "Nginx", done.
You can using start.bat and stop.bat to realize the same effect.
start.bat
#ECHO OFF
REM Start Nginx
tasklist /FI "IMAGENAME eq nginx.exe" 2>NUL | find /I /N "nginx.exe">NUL
IF NOT "%ERRORLEVEL%"=="0" (
REM Nginx is NOT running, so start it
c:
cd \nginx
start nginx.exe
ECHO Nginx started.
) else (
ECHO Nginx is already running.
)
stop.bat
#ECHO OFF
REM Stop Nginx
tasklist /FI "IMAGENAME eq nginx.exe" 2>NUL | find /I /N "nginx.exe">NUL
IF "%ERRORLEVEL%"=="0" (
REM Nginx is currently running, so quit it
c:
cd \nginx
nginx.exe -s quit
ECHO Nginx quit issued.
) else (
ECHO Nginx is not currently running.
)
SC.EXE will only work for executables that already support the Windows Services API and can respond properly to start and stop requests from the Services Control Manager (SCM). Other regular applications, not specifically written as a service, will simply fail to start (usually with error 1053)...
For those exe's, you need a "service wrapper" -- a small utility that can accept the start/stop commands from the SCM and run/terminate your application accordingly. Microsoft provides Srvany (which is free yet very basic), but there are several other free and commercial alternatives.
BTW, you should check out this guide showing how to run Nginix as a service, especially step 7 which discusses how to stop Nginix properly. Not every wrapper will support that functionality (Srvany doesn't)...
The easiest way I've found, was using the Chocolatey package manager.
Once Chocolatey is installed, you open an administrative prompt and type:
choco install nginx
You now have a Windows service named 'nginx' running.
NSSM is the best tool to run Nginx as a service.
If you do not want to use any external 3rd party software then you can implement any of these two methods.
Windows Task Scheduler
Windows startup shortcut
Windows Task Scheduler
As mentioned in this answer prepare one start.bat file.
Put this file where nginx.exe is present.
Open windows task scheduler and set up the task as described in this answer to run it indefinitely.
Do not forget to run this task as the highest privilege with the system account, more details can be found here.
Make the task to start daily at a certain time, through the bat file it will check whether the service is already running to avoid creating multiple nginx.exe instances.
If due to some reason Nginx shuts down, within 5 minutes it will start.
Windows Startup shortcut
Create one shortcut of nginx.exe and put it in the startup folder of Windows.
Follow this answer to find your startup location.
Nginx will run automatically whenever you log in to the system.
This one is the easiest. However, it is dependent on user profile i.e. if you are running Nginx on a server, it will run only for your user account, when you log off it stops.
This is ideal for dev environment.
Download zip file from here.
Extract nginx-service.exe from winginx\build and run it.
Rather than turning nginx into a service, or using CMD to start a process, which really doesn't seem to work. I found that Powershell makes it easy to startup nginx as a detached process. I've combined starting nginx with PHP. Below is the script, named "start-nginx.ps1"
$fcgiPort = "127.0.0.1:9000"
$PHPini = "c:\php\php.ini"
$ErrorActionPreference = "SilentlyContinue"
function restart {
Push-Location /nginx
Stop-Process -Force -Name nginx
Start-Process ./nginx.exe -WindowStyle Hidden
Stop-Process -Force -Name php-cgi
Start-Process "c:\php\php-cgi.exe" -ArgumentList ("-b" + $fcgiPort + " -c " + $PHPini) -WindowStyle Hidden
Pop-Location
}
restart
This script can be executed from any directory, but needs to be customized for where your nginx installation is located.
This script includes a silent attempt to kill nginx and PHP before launching both.
Windows systems are supposed to recognize ".ps1" files as powershell, even in the CMD prompt.
I created another small script to kill the running processes, which simply removes the "start-process" lines from this file.
To run at startup, I used the win-R command to navigate to the directory shell:startup
Placing a shortcut to the startup script in this directory, nginx starts at boot!
Powershell also includes a much more sophisticated ability to schedule tasks, and it is possible to schedule this script to run at startup. See This Link
From the article:
>powershell
$trigger = New-JobTrigger -AtStartup -RandomDelay 00:00:30
Register-ScheduledJob -Trigger $trigger -FilePath $HOME/start-nginx.ps1 -Name startNginx
Combined, I think this approach gets you everything you'd need from an nginx windows service and doesn't require any third-party applications.
Official nginx wiki referes on winginx for this purpose. It builds exe-installer in linux environment.
Process looks like this:
sudo apt-get install nsis make
wget https://github.com/InvGate/winginx/archive/master.zip
unzip master.zip
cd winginx-master/
make
ls -lh ./build/nginx-service.exe
To get actual versions you should specify them in Makefile.

Distributed mongo in windows

How to configure distributed mongodb installation in windows?........
You can install mongodb on Windows as service, for example:
download mongodb: http://www.mongodb.org/downloads
Unzip into c:\mongo
create dir c:\mongo\data
create file: c:\mongo\config.txt
dbpath = c:\mongo\data
bind_ip = 127.0.0.1
noauth = true
install as windows service from command prompt
C:> c:\mongo\bin\mongod.exe -f c:\mongo\config.txt --logpath c:\mongo\log.txt --install
start service
C:> net start mongodb
As for distributed installation, there should not be anything Wondows specific. Just follow the documentation (Replication and Sharding) and change your configurations for your needs.

How to Manually create an Apache Windows Service

I accidentally removed my Apache windows service trying to install another Apache web server. Does anyone know how I can create another Apache windows service from cmd? I tried "sc create ..." but I am missing a script on the end like -k start? Not sure what I need for the end of it...
I am running Apache 2.2
Thank you
On Apache 2.4 the executable have changed name to httpd.exe, the command would be:
httpd.exe -k install -n "Apache2.4"
With a name switch in order to give the service a distinct name.
For older versions of Apache:
Apache.exe -k install
net start apache2
Click Win + R and type cmd
Below Image shows how to install Apache2.2 in windows
Default installation location of Apache2.2 is C:\Program Files\Apache Software Foundation but in my pc I installed directly on C:/ drive.
If you want to install Apache2.2 in Program Files folder then in type in command prompt as follows
C:\>cd Program Files ( Click Enter )
C:\>Program Files>cd Apache Software Foundation ( Click Enter )
C:\Program Files\Apache Software Foundation>cd Apache2.2 ( Click Enter )
C:\Program Files\Apache Software Foundation\Apache2.2>cd bin ( Click Enter )
in bin folder you will find httpd.exe file
C:\Program Files\Apache Software Foundation\Apache2.2\bin>httpd.exe -k install( Click Enter)
The successuful message is displayed in command prompt like above shown in the image.
On Apache 2.2, the command is:
httpd.exe -k install
In Windows 7 or 8 right click the XAMPP Control Panel start (menu) shortcut and Run As Administrator. Then just click the service check boxes for Apache and/or MySQL.
Did not work for me using httpd.exe -k install, I had to register apache as a service using sc.exe using:
sc.exe create apache2.4 start= auto obj= "<account>" password= "<password>" DisplayName= "Apache 2.4" depend= "Tcpip/Afd" binpath= "\"c:\wamp\bin\apache\apache2.4.33\bin\httpd.exe\" -k runservice"

Resources