It seems they've wrapped their offline tool in a service manager which is the aforementioned Non-Sucking Service Manager.
The purpose of this service manager seems to be to restart the GST offline tool should it crash.
Let me guess what happened. Infosys hired the cheapest person they could find to write a program to parse some GST receipts and convert to some XML format. Cheapest person writes code in which every error condition is ignored so the offline tool crashes on 90% of real-world data. Users complain on Twitter that the GST offline tool constantly crashes. Infosys hires the second cheapest person they could find to fix the crash. What's cheaper than rewriting the code? Slap a bandaid on it that will just restart it when it crashes.
I'm not OP, but I run a Windows server at work and my experience is more on the open source side of things.
What Linux has going for it is that pretty much anything and everything is configured with plain text files. It's really easy to figure out how to do anything. Whereas, on Windows Server, to even register so much as a service, you have to get the system to put it in the Registry, and then the service itself has to support built-in Windows APIs for services for monitoring and controlling.
I ended up just saying "screw this" and used NSSM (http://nssm.cc/) to launch my service as a plain old process the way I'm used to.
That and things like being forced to use Remote Desktop to go in and change things most of the time (aside from the few things you can control via sc
and PowerShell and friends remotely) made me really hate Windows Server.
You probably will need to use something like nssm or built in task scheduler to execute a script on boot to remove the quick access item. Someone made a good Powershell function for this.
Use like:
.\Set-QuickAccess.ps1 -Action Unpin -Path "\path\or\drive\letter\to\google\drive"
Same for the drive label, if it is assigned the same driver letter on every boot you can use a Powershell script like
$drive = gwmi win32_volume -Filter "DriveLetter = 'E:'" $drive.Label = "El goog" $drive.put()
There are probably better ways to do these things, but they are what I would do because it seems simple enough.
You have to provide a mechanism that detects if your script is running and restart it if not. Implementing this is really faulty and therefore I'd not recommend that at all. Therefore you have to use some daemon (linux) or service (windows). You did not specify what operating system you are working with but however those are the ways I'm most happy so far:
For Linux I've used daemon-tools very often, because handling is very easy and seems to be rather stable: http://cr.yp.to/daemontools/faq/create.html. So all you have to write is a bash script that executes /usr/bin/php YOURSCRIPT
When using a Windows Server (poor you) you have to install a service. I found that http://nssm.cc/ was rather usefull. You have to write again a script with a line similar to the one above and call that in this service.
This is actually quite simple to do, I do this with a lot of my scripts.
Your PowerShell script called saved at C:\Scripts\Monitor.ps1:
Function Start-Monitoring { While ($true) { # Do things lots
# Add a pause so the loop doesn't run super fast and use lots of CPU
Start-Sleep 30
}
}
Now when you dot source your function and call Start-Monitoring the script will run until we tell it to stop.
Next step is to install the script as a service. The easiest way to do this is using NSSM - http://nssm.cc/
As an example of using PowerShell to install a PowerShell script as a service using NSSM:
Start-Process -FilePath .\nssm.exe -ArgumentList 'install YourService "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe" "-command "& { . C:\Scripts\Monitor.ps1; Start-Monitoring }"" ' -NoNewWindow -Wait
Now you have a service which when started, runs the script constantly.
If you need more details you can check out one of my scripts which I run a service here: https://github.com/MattHodge/Graphite-PowerShell-Functions/
You can force Win to forget a network by running
netsh wlan delete profile name="[PROFILE NAME]"
You could try to run this as a scheduled task at system startup; if this gives you any issues (which it might), you can always resort to: http://nssm.cc/usage ;)
You should be able to use The Non-Sucking Service Manager to run the batch file that starts up your miner script/command. I've not done this with mining, but I have done it with regular batch files and windows executable files. So you may need to experiment with some of the settings - especially for shutdown/exit.
Not sure why but your comment doesn't show up for me. I can see it in your post history but..
> That is, because your testdeploy-notepad.exe is not a service. You have to adjust your application (e.g. ServiceMain), or use an application like srvany.exe to run arbitrary applications as a service.
I would also suggest /u/hou8182 look into NSSM
I have managed to set up node.js on IIS using IISNode, but I have been unhappy with several of the choices made there, particularly that it's impossible to serve root path (i.e. "GET /" ) without URL rewriting which is unbearably slow.
I assume your enterprise requires windows for administrative reasons, which is fine, but I highly suggest you consider dropping IIS entirely or perhaps only to serve static content such as images.
Instead, consider using NSSM to install your node app as a Windows Service. Once you are comfortable with this, look into using Winser which does a great job of integrating NSSM with Node and NPM.
Edit I only just realized I hadn't asked what your actual problem is. So..... what are you trying to do that's failing to work?
Use Windows Task Scheduler in combination with a batch file, or something like Launcher Service or nssm to run your app as a service.
HTH
For nssm:
For sc:
sc.exe create <new_service_name> binPath= "<path_to_the_service_executable>"
I followed these instructions from u/Stryker412:
> Instructions for Windows thanks to r/wilsonic
Download the binary from https://gitlab.com/DEFENDORe/pseudotv-plex/-/releases (Latest version appears to be 0.0.5)
Download ffmpeg binary from https://ffmpeg.org/download.html
Put them in a easy to remember folder eg. C:\pseudotv
Run this command from Start+R
C:\pseudotv\pseudotv-win-x64 --port 8000 --database C:\pseudotv
A cmd prompt window should appear.
Check its running at localhost:8000
Press Ctrl+C to close the cmd window.
Now to make it a service so it runs automatically.
Download nssm http://nssm.cc/download
Extract nssm.exe to C:\pseudotv for simplicity
Start+R again
C:\pseudotv\nssm.exe install
Select the pseudo exe in the path.
Click install service.
Start+s > services
Scroll down to find pseudotv in the list. Click on it and start.
Again check localhost:8000, it should be up and running again.
Continue with setting up pseudotv as per gitlab instructions.
Make sure to add ffmpeg.exe location in settings
C:\pseudotv\ffmpeg\bin\ffmpeg.exe <
I got to ‘again check localhost:8000’ and the window would open for maybe a split second. I tried to do the following step, but I don’t understand the GitLab instructions.
OK so an update to what I've found, using nssm I am able to run Awesome Miner as a service, however the option to run interactively is only supported on the local system account. You need it to run interactively to access the GUI. When I ran it this way AM had no miners set up and it was like a fresh install.
In theory this would work as a service if I wanted to register AM and set up all my miners again under the local account, and every time you ran Awesome Miner it would have to be ran as the local user.
Unfortunately all the AM settings are saved on my user account, not the system account.
As a workaround I think I will do the Windows auto logon thing that you mentioned and put a .bat job in my startup folder that will immediately lock the screen after signon. That is not the best solution but It looks like it might be the easiest.
Native AM support as a Windows service would be great though, I'm not sure why it isn't an option already.
Everyone else here is correct in telling you that you're re-engineering something that has already been done to death a million billion times. As they've stated, you want anything like this running as a windows service. That way, it's trivial to keep them running and doesn't require you logging into the servers.
If these processes are your own tools, then I highly recommend TopShelf as a way of turning them into Windows Services. You might have to pull away some UI code or whatever but that's not all that difficult and is much cleaner in the end.
If you don't have source access, you can still turn standalone things into services using something like NSSM.
Again, as others have stated, you want all these kinds of things to deploy as Windows Services, that way they can automatically run after a reboot, you can create scheduled tasks to ensure they're still running and you don't really need much else.
IF you still want a fancy UI on top of them to monitor this stuff, Powershell is the way to go. IF you absolutely must have a WPF UI written in CSharp, you can use something like WMI to get remote service info but really this isn't the best way to tackle it.
Focus on the automation of your environment rather than manually checking and starting things. If something is running as a "service" in the sense that you want it on a remote server and always available, treat it like an actual Windows Service.
Another benefit of actual windows services, is that it's a lot easier to automatically deploy them to new machines. Again, automation is key - imagine this, you make a code change, hit "commit" and 10mins later all of your servers are up to date without anyone having to lift a finger. That's achievable with the above strategy.
It's been a while, but I remember having success with this back when I used xbmc as a shell: http://nssm.cc/
Basically if a program is setup to run as a service, it'll get loaded regardless of the shell used.