creating a GNU screen during deployment by AWS codeDeploy

65 Views Asked by At

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:

  1. How to get codeDeploy running the application inside a screen
  2. Is it even a decent way of deployment? Maybe I am not supposed to do that at all.
1

There are 1 best solutions below

0
On

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