Run Python Script (On Network Drive) as Windows Service with NSSM - python

I have followed around 5 tutorials on using NSSM to run a python script residing on a network drive. It creates the service, I can edit the service but when I start the service I get the following error:
Unexpected status SERVICE_STOPPED in response to START control
When I try starting the Windows-10 service from Services I get the following error:
Services error during start
I have changed the path to the python script from the full network path to a mapped network path and that did not change anything.
I have also tried using Task Scheduler which worked once in a while and was intermittent and I also tried the pywin32 method as posted here but it fails to start the service as well.

I figured it out. On my remote VM it does not allow Local System Account to be set as the Log on. It required me to add an admin user name and password. It's running now.

Related

Jenkins on Windows: UE4 packaging for iOS fails with "Host key verification failed."

I have this Jenkins server running on my Windows machine. What the jobs do is it runs some python code that is also on the same machine, to package .ipa file (for iOS) using UE4 engine and ships it.
Everything works just fine if I run python code locally. But when I run it through Jenkins, it will fail at some point where UE4 is trying to sign the package. This is partial error message I'm getting.
Using remote server 'XXX.YYY.ZZZ.56' on port 22 (user '***********')
[Remote] Using private key at ...\RemoteToolChainPrivate.key
ERROR: Unable to determine home directory for remote user. SSH output:
Host key verification failed.
I think for some reason Jenkins doesn't know where ssh related stuffs are located in windows.
How can I fix this issue?
Assuming you installed Jenkins as a Windows Service, then Jenkins is probably running as another user (not the user you sign in as).
In the Services app, you can change the user the service is running as if necessary. You can find the Services app here:
C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Administrative Tools\services.lnk
See About Services for more info.
That explains why the remote cannot find the home directory (because the remote user has a different name than the service account user) and also why the host key verification failed (since you never accepted the host key as the service account user).

Apache service wont start through windows services

Using Apache2.4
I could able to start the server and listen on port 8080 through powershell or cmd.
I created a windows service using
httpd.exe -k install
and I could see the service installed as Apache2.4.
When I try to start the server through the windows service it fails with below error, whereas I could able to start the apache server from cmd(run perfectly).
Error output here
When this problem appears and but running httpd through cmd works fine, Please see in event viewer to see the detailed error
Run -> eventvwr -> windows -> Application ->
If you can run httpd.exe via command line, but are unable to start it as a service; the problem might be in folder permissions.
(as stated by Pradeep, see:) Run > eventvwr > windows > Application > ...
If the error is:
DocumentRoot must be a directory .
Make sure that all paths with DocumentRoot, you have added in your apache config, can be accessed by the service.
Right click the folder
Select Properties
Go to the "Security" tab
Default values (in my case, windows 10 pro) are:
Authenticated Users
SYSTEM
Administrators (PC-Name\Administrators)
Users (PC-Name\Users
One of the folders in DocumentRoot did not have the above users listed, but only my hotmail account, meaning the system was unable to access the specific folder.

Running a python script as a windows service after converting to exe

I have a python script which is raising a socket for communication purposes, I've managed to convert it to exe using Pyinstaller and run it successfully by double clicking on it.
I tried to make the exe a windows service using the following guide but when I ran the service through services.msc, I got:
Windows could not start the test1 service on Local Computer
Error 1053: the service did not respond to the start or control request in a timely fashion
I wonder whether each python script can realy become a windows service, or it has some criterias , as I didn't see this in the guide above.
I tried to take it more simple ,and created a python script of the following code:
while True:
z = 10
print z
Now I created an exe file and a service, when trying to run it I got:
Windows could not start the test1 service on Local Computer
Error 1067: the process terminated unexpectedly
Can somebody please direct me, what am I doing wrong?

Error: Failed to Write, Broken Pipe when running python script on AWS EC2 instance

I'm new to cloud computing in general, and I've started a free trial with Amazon's Web Services, in hopes of using their EC2 servers to run some code for Kaggle competitions. I'm currently working on running a test Python script for doing some image processing and testing a linear classifier (I don't suspect these details are relevant to my problem, but wanted to provide some context).
Here are the steps I've gone through to run my script on an EC2 instance:
Log in to AWS, and start EC2 instance where I've installed relevant Python modules for my tasks (e.g. Anaconda distribution). As a sidenote, all my data and the script I want to run are in the same directory on this server instance.
SSH to my EC2 instance from my laptop, and cd to the directory with my script.
Run screen to run program in background.
Run script via python program.py and detach from screen session (ctrl + A, D)
Keep EC2 instance running, but exit from SSH session connecting my laptop to the server.
I've followed these steps a number of times, which result in either (a) "Broken Pipe" errors, or (b) in an error where the connection appears to "hang". In the case of (b), I've attempted to disconnect from the SSH session and reconnect to the server, however I am unable to do so due to an error stating "connection has been reset by peer".
I'm not sure if I need to configure something differently on the EC2 instance, or if I need to specify different options when connecting to the server via SSH. Any help here would be appreciated. Thanks for reading.
EDIT: I've been successful in running some example scripts using scikit-learn by setting up an iPython notebook, launching it with nohup, and running the code in a notebook cell. However, when trying to do the same with my Kaggle competition code, the same "hanging" issue happens, and the connection appears to be dropped, causing the code to stop running. The image dataset I'm running the code on in the second case is quite a bit larger than the dataset processed by the example code in the first case. Not sure if dataset size along is causing the issue, or how to solve this.

How can I execute Adobe After Effects via an EC2 Windows Server 2012 Instance?

I have an After Effects script that renders a custom video based on strings passed to it via a webpage form and some python code. It runs just fine when I execute the python code from a remote desktop connection using the administrator account. However when I try to execute it via the web page I can see that After Effects blinks on for a second in the Task Manager but it fails to output any files like it does when run as the administrator.
I'm assuming this is due to some crazy permissions issues with IIS. I've added the after effects executable directory as a virtual directory in IIS. I've also allowed the after effects executable file in the CGI restrictions. I've also set the executables folder to allow read, write, and execute permissions for the IIS-User account.
Any ideas?

Categories