Working with screen

Since we are using DevStack in this book, screen becomes a core concept of running DevStack. In this section, we will take a look at some screen commands and how we will be using them in order to interact with DevStack.

Screen is software that essentially is a window manager in Linux. It helps the user to use multiple shell windows from a single SSH session. This is recommended to be used when we have a long running command that needs to survive network disruptions.

Screen is normally used to run long running processes. DevStack creates and runs its entire services in its own screen and if you were to use the ~/devstack/restack.sh script, it would connect you to the already running screen session.

We installed screen as a prerequisite earlier in the chapter; let us now look at some of the commands that will help us.

Screen control key

Pressing Ctrl + A activates the control mode and any key you press after that is passed as a control key and not as a key press sent to the shell.

In order to use this, you have to press Ctrl + A, release, and press the key that you want to send as a command.

For example, for help, you would press Ctrl + A, release it, and then press the ? key.

Useful commands

Some of the useful commands in screen are as follows:

  • screen <screen name>: To create a new screen session
  • screen –ls: To list all the screen sessions
  • screen –r <screen name>: To reconnect to a screen
  • screen –X –S <screen name> <command>: To pass a command to the screen

Once inside the screen, the following commands can come in handy:

  • Ctrl + A and then ?: Screen help page
  • Ctrl + A and then " (Control key and double quotes): List of all windows in a screen (especially helpful to select the different services running in DevStack)
  • Ctrl + A and then C: Create a window in screen
  • Ctrl + A and then N: Go to next window
  • Ctrl + A and then D: Detach from the screen
  • Ctrl + A and then K: Kill the screen

DevStack and screen

Since DevStack runs in the screen called stack, we will be able to use all of the commands in order to manage the DevStack system. The screen windows keep debug logs of all the different services.

We should be able to find the screen name using the screen –ls command. The DevStack default screen name is Stack.

DevStack and screen

We could connect to it using the command screen –r 20276.stack (the name shown in the previous command output).

We can then see all the different services at a glance by using Ctrl + A and then ".

DevStack and screen

We could switch to the window running a particular service by using the up and down arrows and hitting enter.

Killing DevStack

We could kill the stack by using the command:

screen –X –S 20276.stack quit

That sends the quit command to the screen thereby killing all the services.

Restarting DevStack services

DevStack installs the services and opens a screen for the services. Since the startup scripts are not installed (like in the case of the production install), in order to restart the services, we will need to use the following procedure:

  1. Connect to the stack screen by:
    screen –r 20276.stack
    
    Restarting DevStack services
  2. You will see a screen like the preceding one.
  3. Browse to the service you want to restart by pressing Ctrl + A and N (for next screen) and Ctrl + A and P, for the previous screen, until you reach the service. Please read the service name at the lower left-hand corner.
  4. We could also use the other methods of navigating the screens as mentioned previously. In this example, we will navigate to the Nova Scheduler Service.
    Restarting DevStack services
  5. Press Ctrl + C to stop this service, and the prompt will return.
  6. Press the up arrow (to see the last command) and press the Enter key to restart. This command is just a long command line with the location of the configuration file.

We could copy this command line and create our own startup scripts should we choose not to use this method.

Restarting DevStack services

The service has now been restarted and we can continue to work on the server. We can use the other features of the screen with DevStack.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset