Restarting a service in Openstack installed using Devstack - openstack

How to restart a specific openstack-service installed using devstack?

Rejoin stack screen as
./rejoin-stack.sh
and move to the specified service page using ctrl+a+", then type the number of the screen you need to go.
Hit 9 and then ctrl+C. The service would be stopped now. Re-run the following devstack command to start the service:
(e.g for nova-network)
cd /opt/stack/nova && /usr/bin/nova-network --config /etc/nova/nova.conf || echo "n-net failed to start" | tee "/opt/stack/stack/n-net.failure"
Hit Ctrl+d to detach from the stack screen.

To run screen command
screen -r
Now, you will be in screen window and you can see the list of Openstack services; Like "q-svc", "horizon", "key-access" in the bottom of the screen;
The current active screen will be marked with * like "horizon*"
To move to specific Openstack service press
"Ctrl + a" and "0-9"
Example: "Ctrl + a" 5
to jump to actual service; You can also move to next or previous screen using the below commands
"Ctrl + a" and n --- > for next
"Ctrl + a" and p --- > for previous
Now to stop and start the service; Go the respective screen window and press
"Ctrl + c"
To stop the service; This will now show the bash screen in the respective screen window; and to start the service, press UP arrow mark to see the last executed command in the screen window and press enter to start the same.
Life is easier with screen to start and stop the Openstack services configured to run with Devstack.

When ./stack.sh completes, openstack is ostensibly running.
as your stack user, you can then issue this command:
screen -dr
this should open up a screen session with windows for each of the services. the services are running from those screen terminal sessions or ptys.
you can simply kill the process and restart it from those ptys.
of course standard logical order of operations apply. if mysql is dead, nova-api won't start up very well. same goes for keystone being off. so, pay attention to dependencies.
if you are unsure of how to execute the services in the terminals, first do a ps auxww | grep service or something to that affect. That should provide some insight on how to run the binaries again.
Good luck.

rejoin-stack.sh was remove according this git commit, you need to do screen -c /path/to/devstack_install/stack-screenrc

Run this command as root (for example: to start keystone service)
$ systemctl start devstack#keystone.service
You can use restart, stop, status, etc. in place of start as your need.
you can use wildcard as well. Like as below.
$ systemctl start devstack#*
=> it will start all devstack services.

Things has changed in new version devstack.
By default DevStack is run with all the services as systemd unit
files. Systemd is now the default init system for nearly every Linux
distro, and systemd encodes and solves many of the problems related to
poorly running processes.
Assuming the unit n-cpu to make the examples more clear.
Enable a unit (allows it to be started):
sudo systemctl enable devstack#n-cpu.service
For more information, visit https://docs.openstack.org/devstack/latest/systemd.html

you can use systemctl start devstack#* to restart every devstack service

Related

How to shut down a computer (host)

I know it sounds weird, but I have a case where Deno would need to shutdown its own host (and kill its own process therefore). Is this possible?
I am specifically needing this for linux (lubuntu), if that's relevant. I guess this requires sudo rights, which sucks but would be an option.
For those interested in details: I'm coding a minecraft server software and if the server has no player for 30 minutes, it will shut itself down to save some power. A raspberry PI that runs 24/7 anyways, has a wake on lan feature, so that it can boot again. After boot, the server manager software would automatically start as a linux service.
You can create a subprocess to do this:
await Deno.run({ cmd: ["shutdown", "-h", "now"] }).status();
Concepts
Deno is capable of spawning a subprocess via Deno.run.
--allow-run permission is required to spawn a subprocess.
Spawned subprocesses do not run in a security sandbox.
Communicate with the subprocess via the stdin, stdout and stderr streams.
Use a specific shell by providing its path/name and its string input switch, e.g. Deno.run({cmd: ["bash", "-c", "ls -la"]});
See also command line - Shutdown from terminal without entering password? - Ask Ubuntu for ideas on how to avoid needing sudo to call shutdown or alternative commands that you can invoke from Deno instead.
To extend on what #mfulton2 wrote, here is how I made it work, so that I did not need to start the program with sudo rights, but still was able to shut down the computer without the use of sudo outside or within the app.
Open or create the following file: sudo nano /etc/sudoer
Add the line username ALL = NOPASSWD: /sbin/shutdown
Add this line %admin ALL = NOPASSWD: /sbin/shutdown
In your deno script, write Deno.run({ cmd: ["shutdown", "-h", "now"]}).status();
Execute script!
Keep in mind that any experienced linux user would potentially tell you that this is very dangerous (it probably is) and that it might not be the very best way. But IMHO, the damage this can cause is minor enough, as it only affects the shutdown command.

What does “&” mean in “linkerd viz dashboard &”? [duplicate]

How can I run a shell script and immediately background it, however keep the ability to inspect its output any time by tailing /tmp/output.txt.
It would be nice if I can foreground the process too later.
P.S.
It would be really cool if you can also show me how to "send" the backgrounded process in to a GNU screen that may or may not have been initialized.
To 'background' a process when you start it
Simply add an ampersand (&) after the command.
If the program writes to standard out, it will still write to your console / terminal.
To foreground the process
Simply use the fg command. You can see a list of jobs in the background with jobs.
For example:
sh -c 'sleep 3 && echo I just woke up' & jobs
To background a currently running process
If you have already started the process in the foreground, but you want to move it to the background, you can do the following:
Press Ctrl+z to put the current process to sleep and return to your shell. This process will be paused until you send it another signal.
Run the bg command to resume the process, but have it run in the background instead of the foreground.
Another way is using the nohup command with & at the end of the line.
Something like this
nohup whatevercommandyouwant whateverparameters &
This will run it in the background and send its output to a nohup.log file.
One easy to use approach that allows managing multiple processes and has a nice terminal UI is hapless utility.
Install with pip install hapless (or python3 -m pip install hapless) and just run
$ hap run my-command # e.g. hap run python my_long_running_script.py
$ hap status # check all the launched processes
$ hap logs 4 # output logs for you 4th background process
$ hap logs -f 2 # continuously stream logs for the 2nd process
See docs for more info.

Ravenscar Task / Program Termination in Native Compilation

As I understand it, one restriction of the Ravenscar profile is that tasks should not terminate.
This certainly makes sense on bare metal, however when testing on a native system (as a executable program) it has the side effect that doing a Control-C to exit the main task leaves the program running in the background.
I plan to move my program to bare metal eventually and would like to be able to use the Ravenscar profile -- how can one allow the program to exit correctly when doing something like this? Abort statements are forbidden. If the Ravenscar profile was not applied, I could easily make this work by allowing tasks to terminate. Right now I am doing a killall -9, which works, but doesn't seem very elegant.
As it turns out, the issue had to do with how I was executing the program. In my case I was doing it over a remote ssh command, eg:
ssh myhost "sudo su -c mycommand"
Adding a -t to allocate a tty fixes the issue, that is:
ssh -t myhost "sudo su -c mycommand"

wi-fi disconnected during crouton installation

I purchased an Asus c300m with the soul aim of developing my linux skills
I followed the instruction to boot in developer mode and execute the following command to start downloading downloading crouton/ubuntu on it
sudo sh -e ~/Downloads/crouton -t xfce
it was going well until my wifi disconnected temporary and i got the following error:
E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?
Failed to complete chroot setup
Unmounting /mtn.stateful_partition/crouton/chroots/precise..
Then I tried to run the sudo command again but I got the following:
/usr/local/chroots/precise already has stuff in it!
Either delete it, specify a different name (-n) or specify -u to update it
However, I'm not sure how to modify the command so i can resume installation or restart it.
You could try sudo sh ~/Downloads/crouton -u -n xfce but it's unlikely that will work. That's from the Crouton docs.
The best approach, since you never finished installing and therefore don't need to recover any data, just delete the install directory and start again. There is no good way for crouton the pick up where it left off.
Also during the install you don't want the Chromebook going to sleep. There is no way in the built-in ChromeOS settings to prevent that but according to this article you can go to the Chrome Web Store and install Keep Awake from Google.
This gives a cool icon in the upper right of the Chrome browser showing a sun, a sunset or a moon depending on what settings you want. Before you start your next install, click it to the sun so the machine won't sleep.
I had the same problem. I ran this and it's downloading:
sudo sh ~/Downloads/crouton -e -t xfce -u
I'm not sure if it's where i left off but it is definitely downloading and reinstalling after the interrupted connection.
Just type in sudo start[desktop environment]
and press y. It should keep going.

Devstack Services

I have installed ceilometer services in a devstack environnement by enabling them in local.conf"
enable_service ceilometer-acompute ceilometer-acentral ceilometer-anotification$
enable_service ceilometer-alarm-evaluator,ceilometer-alarm-notifier
enable_service ceilometer-api
enable_service ceilometer-aipmi
but I can not list the services when I do a rejoin-stack.sh and type Ctrl + a + ".
How I should resolve this problem, because I need to restart the ceilometer services as I am installing kwapi ?
Thank you in advance .
Ceilometer is middleware that is used by the other services. To "restart ceilometer" you should restart the entire stack with ./unstack.sh followed by ./stack.sh. If you want to uninstall and re-install, you could run ./clean.sh followed by ./stack.sh.
When you wanna restart services with devstack, have 2 main ways:
Run ./rejoin-stack.sh and press ctrl C + ctrl D to kill all services. Then re-run ./rejoin_stack.sh and press ctrl A + ctrl D for detaching. Then, all services were restarted.
Run "ps -ef | grep your_service_name" to find and kill the service that you need to restart. When you run above command, you will find the exact command to start that service. :D
But, I recommend you use the first way when restart any service with devstack. It is the best way to make your system run smoothy.
First cd to folder devstack
You can find the file ./rejoin_stack.sh
Execute the same.
It will be executed and screen will be opened for access.
press ctrl + a + shift + "
Then it will be listing the running services
can move to service which needs to be stopped by scrolling towards it.
on the service which is needs to be stopped press enter
then press ctrl + c , it will stop the service
then press up arrow key to run the service again
service will be restarted successfully.

Resources