4

I currently have the uwsgi Install uwsgi package installed. I would like to remove the package but leave the current uWSGI instances running. Is this possible?

(Yes, I do realize the service will only continue running until it is stopped or the server restarts.)

Nathan Osman
  • 32,495

2 Answers2

9

The prerm of uwsgi script contains this:

#!/bin/sh
set -e
# Automatically added by dh_installinit
if [ -x "/etc/init.d/uwsgi" ] || [ -e "/etc/init/uwsgi.conf" ]; then
    invoke-rc.d uwsgi stop || exit $?
fi
# End automatically added section

You have a few options:

Edit the prerm script.

The script is usually located at /var/lib/dpkg/uwsgi.prerm. Do:

sudo sed -i '/invoke-rc.d/ s/^/#/' /var/lib/dpkg/uwsgi.prerm

to comment out the command that stops the service.

Use the conditions in the script to your advantage

Either:

sudo chmod -x /etc/init.d/uwsgi

since the script checks for execute permissions of this script,

Or:

mv /etc/init/uwsgi.conf /etc/init/uwsgi.conf.bak

since the script checks for existence of this Upstart service file.

According to the list of files, the package has /etc/init.d/uwsgi and not the Upstart script.

(Mis)Use policy-rc.d

invoke-rc.d is controlled by policy-rc.d. However, using it directly has a problem. The prerm script is has exit $?, and dpkg doesn't like non-zero exit codes. Hence, this will still require changing the prerm script:

echo 'exit 101' > /usr/sbin/invoke-rc.d
chmod +x /usr/sbin/invoke-rc.d
sed 's/exit/echo/' -i /var/lib/dpkg/uwsgi.prerm

Why did I even answer?

There are some brilliant answers already available: Install packages without starting background processes and services (possibly with some slight adaptation required).

muru
  • 207,228
1

You could just keep the package installed until shutdown. That will accomplish relatively the same thing.

Do this by running this command as root:

echo "sudo apt-get remove uwsgi" > /etc/rc6.d/K99_script

followed by:

chmod +x K99_script

When you shutdown, the package will automagically be uninstalled.

Note, though, that after your system comes back up, you should delete the K99 script file.

Kaz Wolfe
  • 34,680