Can't stop my custom windows service via gitlab-runner - gitlab

This is my first question on stackoverflow. Hope your eyes won't be bleeding too much from my English.
Long story short: I can't stop my custom windows service via gitlab-runner.
What I'm trying to achieve during gitlab CI\CD is:
send a signal to my service to stop doing his job
periodically check this service status to determine whether it is stopped or not
So, I've install shell gitlab-runner locally for ease and gitlab server sees my local runner.
My windows service has name in the following format: "My.Service.Name".
gitlab-ci.yml contains job <my_job_name> with following command inside script section sc.exe queryex My.Service.Name (trying to get service status).
Command execution gives me error [SC] EnumQueryServicesStatus:OpenService FAILED 1060: The specified service does not exist as an installed service.
Basically, sc.exe stop My.Service.Name also failed with error [SC] OpenService FAILED 1060: The specified service does not exist as an installed service.
My service was created this way: sc create My.Service.Name binPath= "path\to\exe\My.Service.Name.exe -service" DisplayName= My.Service.Name start= delayed-auto depend= MSMQ.
Local query result of sc.exe queryex My.Service.Name call.
I was already checked this:
my service exists and has same service and display names in services.msc (My.Service.Name)
service name didn't contain any spaces (in case of missing quotes)
simple command sc.exe queryex (via gitlab-runner) gives me not all services, that I can see in services.msc locally
alternative command also not giving me all services from services.msc Get-Service -ComputerName . (via gitlab-runner)
same commands executed locally gives me desired result via both sc.exe sc.exe queryex My.Service.Name and
Get-Service in PowerShell Get-Service | where {$_.name -like "*My.Service.Name*"} or Get-Service -ComputerName .
both services gitlab-runner and My.Service.Name are running with my local administrator account
local run gitlab-runner.exe exec shell my_job_name gives me desired result also, so I can query service information and even stop service
based on similar questions, I also checked that windows RPC services are enabled and currently running
So, why some services, including my service, are not listed in results of sc.exe and Get-Service (via gitlab-runner)? I suspect some permission issues here.
Any help will be appreciated.

I finally get what is wrong - I messed up with gitlab-ci.yml job tags and in fact, another gitlab-runner processed incoming build. Now it's working as expected.

Related

Azure App Service - Install .msi using Azure DevOps Pipeline or Kudu terminal

Need to install LibreOffice to my Azure App Service.
1. Azure DevOps
I used powershell Start-Process to silent install but getting Permission denied.
Start-Process: /home/vsts/work/_temp/5cc8c99d-ed13-4b1b-823b-3cd9b56fdd1b.ps1:5
Line |
5 | Start-Process /home/vsts/work/1/s\LibreOffice_7.4.0_Win_x64.msi -Argu …
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| An error occurred trying to start process
| '/home/vsts/work/1/s/LibreOffice_7.4.0_Win_x64.msi' with
| working directory '/home/vsts/work/1/s'. Permission denied
2. Kudu terminal
Getting Access Denied error when trying to run Start-Process manually.
Are there any alternatives to achieve this?
Not possible to install something on the host. The alternative is to use a docker container which has it already installed.
https://azure.github.io/AppService/windows-containers/
App Service supports Windows Containers! Deploying your application in a Windows Container enables you to bring along dependencies such as custom fonts, cultures and GAC deployed assemblies. When deploying a containerized application, the Windows Container is an isolation and security boundary. As a result, calls to libraries that would normally be blocked by the Azure App Service will instead succeed when running inside of a Windows Container.

Not able to run an exe , powershell located on remote client machine using release Pipeline Azure Devops

Actual i have installed a self hosted agent on my local machine
now my issue is when i am running a release pipeline for a client machine i have a powershell task in which i have a command that runs an exe file located in client machine which displays a message box .
but when I am checking at client machine i am able to see the exe is running in task Manger during the execution of my release pipeline but show how i am not able to see the interface of the application .
You can try adding -Wait to your powershell command. For below example.
Start-Process -FilePath "path to programm.exe" -Wait
You also need to make sure the deployment agent(the agent installed on client machine) is running in interactive mode.
To configure the agent in deployment group to run in interative mode. You need to change the Registration script you copied in azure devops. Remove --runasservice when you run the registration script on the client machine
Then you will be asked to set the agent to run as service or not as below screenshot(Please enter or type N to select interative mode) during the setup.
Check Interactive vs. service for more information.

Kentico Continuous Integration - Login failed for user

I'm trying to get Kentico Continuous Integration running as a step in my CI process. However, I'm encountering the following error when my deployment script runs:
Running Kentico Continuous Integration...
Continuous Integration Console
Kentico Software
System.Exception: Login failed for user 'MACHINE-NAME\ci-runner-user'.
at CMS.DataEngine.CMSApplication.ReportApplicationError(String message)
at CMS.DataEngine.CMSApplication.Init()
at CMS.ContinuousIntegration.ConsoleApp.Program.InitKenticoApplication(String webAppPhysicalPath)
at CMS.ContinuousIntegration.ConsoleApp.Program.Deserialize(String webAppPhysicalPath)
at CMS.ContinuousIntegration.ConsoleApp.Program.Main(String[] args)
How do I enable the local user my deployment script runs as to successfully execute ~\CMS\bin\ContintinuousIntegration.exe -r?
My initial thought is that you’re using integrated security in the web.config - make sure that the user you mention has SQL access for your Kentico DB
You need to allow PowerShell ISE to run unrestricted. To do so follow these instructions:
Install or make sure PowerShell ISE is installed
Run PS as Administrator
First time only - run this command in PS ISE, "Set-ExecutionPolicy Unrestricted". It should show LocalMachine as Unrestricted. This will allow you to execute the script for CI Restore

Unable to connect with Azure Container Services - Kubernetes

I am working on setting up environment for deploying microservices.
I have gotten as far as building my code and deploying to a registry but having problem running it in Azure Container Services.
I am following this guide to connect to ACS: https://learn.microsoft.com/en-us/azure/container-service/container-service-connect
But i fail on the step: Download Cluster Credentials
Using the given command
az acs kubernetes get-credentials --resource-group=<cluster-resource-group> --name=<cluster-name>
Ofc changing the reseource group and clustername to the correct names from my portal. I get an error:
[WinError 10049] The requested address is not valid in its context
(if i change resource group or clustername to something else I get other errors so seems it can find those at least)
When i try to search for the error it seems to be some IP adress problem but can't figure out what to do. Tried running same command from other network (from home) to make sure work firewall is not blocking something.. but I get the same error
Any help appriciated!
This command copy the cluster credentials to your machine. Background processes are ssh to your cluster VM and copy the credentials.
So, you should ensure you could ssh to the master VM manual. If you could not ssh to master VM manual, az command also could not do it. You could get your master-dns-name on Azure Portal.
ssh -i id_rsa <user>#<master-dns-name>
Notes: If az command does not work and you could ssh to master VM, you could download credentials to your machine. They are same. You could check your link about this.
You also need check your azure cli version. You could use the following commands
az --version
My version is 2.02. It works for me.

Deluge Windows Service

I am trying to run the DelugeD.exe as a windows service. After installing Deluge and creating the services using NSSM, I try to start the service and get the following error:
Windows could not start the Deluged service on Local Computer. The service did not return an error. This could be and internal Windows error or and internal service error. If the problem persists, contact your system administrator.
I have created the Deluge-web-debug.exe as a Windows Service and it successfully starts. When I browse to http://localhost:8112 the web client appears, however the Connection Manager shows the Deluged daemon has not started.
No error, no logs, what could be the cause?
Thanks!
I thought I would start from scratch, reinstall deluge for windows, and try again. After this it still failed.
Using nssm, the error was:
deluged: Unexpected status SERVICE_PAUSED in response to START control.
This placed the service in a perpetual Paused state.
Finally, I decided to tear down the services using nssm remove, kill any running deluge processes, then delete the Config folder where deluged was pointing.
I am certain deleting the Config folder and all files was what solved the problem, and now it starts successfully.
I think I just solved this one by checking the "Allow service to interact with desktop" box under the LogOn tab for both the Deluge daemon and the WebUI services I created with nssm:
"Allow service to interact with desktop" in services.msc

Resources