creating a GNU screen during deployment by AWS codeDeploy - linux

I am trying to create a Linux screen during the deployment using AWS codeDeploy.
The purpose is to run the application inside a screen. I want codeDeploy being able to create a screen in detached mode and start the application inside it.
I tried these commands in AfterInstall and BeforeInstall stages:
screen -RS
screen -dm
But, when the deployment finishes successfully, the screen has not been created.
Also, if I try to send a command to the screen that I have tried to create in the previous stage, I get this error:
[stdout]Must be connected to a terminal.
So, my questions are:
How to get codeDeploy running the application inside a screen
Is it even a decent way of deployment? Maybe I am not supposed to do that at all.

Well, I had made a couple of mistakes that caused the failure.
codeDeploy runs under root user by default. And any screen it creates is not visible to other users. You may want to run codeDeploy as another user (there is a tutorial in Amazon for this), or run your commands in the codeDeploy scripts with runuser (as a user other than root)
any try to attach to a screen (or create a screen in the attached mode) is doomed to fail, because codeDeploy is not connected to a terminal. You need to create the screen in the detached mode. For example, by: screen -dmS name

Related

Using pyautogui.screenshot in AWS Workspaces

I'm running a python script in the AWS Workspaces to take a screensot of my entire desktop (inside AWS).
The script is working fine but when I "ended" the AWS Workspace, the screenshot being taken is the login page. Please find attached.
Inside the AWS Workspace, I already did any possible ways to prevent "my computer" from sleeping. Likewise, its Running Mode is AlwaysOn.
What I want to achieve is even though my AWS Workspace is not "active" I want my python script to capture the active desktop not the login page.

Post-build actions in Python/Linux webapp do not run

I have a Django-based web app deployed from Github, running in Python 3.9. The app deploys and starts successfully.
I need to add post-build actions to complete the deployment; the exceeding common Django task of running "manage.py". Following the general and python-specific docs I have added the an app setting of
POST_BUILD_SCRIPT_PATH=postbuild.sh
There is a shell script, postbuild.sh in the root of my app, which runs fine if I SSH into the running container. The expected behaviour is that after deployment, this should run, and output to the deployment log. Neither of these things happen.
I have tested the app setting POST_BUILD_COMMAND with a very simple echo, and that does nothing either.
Can you tell me either what I need to do to make these app settings work, or suggest an alternative method of running the post-build script?
Please note that this is a Linux app using Oryx, so answers concerning Windows/Kudu like this one aren't related.
I noticed you asked your question over here as well. Your setting needs to be set to a relative path, /postbuild.sh.

Debug scenario for lambda

As usual many things to do and no time to do it, so I need some suggestions.
This the scenario. AWS Lambda development based on SAM cli (aws cli/sam cli/docker/IntelliJ with AWS plugin) on Ubuntu 18.04
Developing a lambda function on node.js 12 - Javascript.
Everything is almost working perfectly. I edit the function, run from IntelliJ, docker is executed with the lambda function, logs are happily popping up.
I say almost because I have a problem.
I create a text file in the function and is saved on /tmp/myTextFile.txt
I would like to be able to see the content of this file.
So I was wondering if exists a way to do it accessing the docker image.
I did try to "debug" the function rather than just execute it, putting a breakpoint after generating and saving the file.
I verified that the docker image remains open when the breakpoint is hit.
Then I did try to attach a terminal to the open docker image, no errors but also nothiing happens.
On a terminal I did open a terminal and :
docker container ls
I did see the docker image opened from the the local SAM development
Then :
docker container attach "ID of the opened image"
and .. nothing.
There is a way to login and execute commands like "ls" or "cat" ?
In this way I could see if the file was generated and if is correct.
Thanks for any suggestion !
Steve

Azure DevOp - Set Screen Resolution interactive mode

Due to fact that my VM is opening in small resolution I've been facing lots of situations with flaky tests, mainly about "Element is not clickable" notification. The solution to my problem might be adding extensions and increase the resolution:
https://marketplace.visualstudio.com/items?itemName=ms-autotest.screen-resolution-utility-task
The problem is I don't exactly know where it should be placed inside my pipeline which looks like this:
In order to run successfully this extensions there is a need to fulfill requirements:
Agent must be configured to run as an interactive process with autologin enabled (Where I should enable that?)
Shall I configure it directly by the "Demands" section on mine "Restart" agent options? I've tried putting the extensions inside the "Restart" section between "Stop" and "Start" agent tasks but it failed...
You can either reconfig your agent to interactive mode(check below detailed steps), or install a new agent and config it to interactive mode on your VM. Check here to install a new self hosted agent and check for more configuration.
1,
To reconfig your agent to interative mode, you need cd to the agent installation folder and run.\config remove to remove it first as shown in below pic.
2,
After agent is removed, Run .\config to reconfig your agent, and choose interactive during the configuration. Please refer to below screenshot and be careful to choose the right option (Y/N) at the highlighted steps
3,
To start the interactive agent by run .\run
Above steps should be ran as administrator. I followed above steps and successfully run set screen resolution task.

How do I grant a cron job webcam access in Mac OSX Mojave?

In OSX Mojave, access to the camera is controlled by pop-up dialogs and the new System Preferences>>Security & Privacy>>Privacy>>camera panel, where apps can be granted (or denied) access to the camera.
I can grant "iterm2" access to the camera, which lets me run imagesnap from the commandline.
I use a cron job to capture a photograph of the cat bed every 60 seconds. This now fails, since upgrade to Mojave, because it does not have permission to access the camera. Is there any way I can give my cron job access? I don't get a pop-up dialog for a cron job.
Using an Automator application wrapper also works. Create the wrapper (run shell script), run in manually and grant it permission. Then the cron job can call the Automator app.
I hacked around this by using a wrapper script that indirects through Applescript to use iTerm, which does have permission, and have cron launch the wrapper.
#!/bin/bash
osascript << EOF 2>&1 | grep -v "window id"
tell application "iTerm"
create window with default profile command "/path/to/capturescript"
end tell
EOF
FWIW - Mojave broke this further, and the Automator app broke.
I lost a lot of time fiddling with it, and then gave up. It seems the security of camera devices changed again. My time is expensive and raspberry pis are cheap; I connected the camera to a pi and now access it from cron with "ssh pi fswebcam - > output.jpg" which works flawlessly.
Open Automator on Mac.
Click New Document.
Choose Application.
In search bar search for Run Shell Script and add to application with click.
Add code for running your desired script (like you would run the script from shell).
On top right click Run.
Allow access to camera.
With installed cronjob you should be fine.

Resources