dpkg删除以停止进程 [英] dpkg remove to stop processes

查看:522
本文介绍了dpkg删除以停止进程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我当前正在运行Ubuntu 12.04.我创建了一个debian软件包,该软件包当前可以成功安装并启动三个新进程.通过将以下脚本放在/etc/init.d中,我也使这三个过程在运行时启动:

I am currently running Ubuntu 12.04. I've created a debian package that currently installs successfully and starts three new processes. I have also made these three processes start at runtime by placing the following script inside /etc/init.d:

# This example is from http://www.debian-administration.org/article/Making_scripts_run_at_boot_time_with_Debian
#  Also used http://wiki.debian.org/LSBInitScripts/

### BEGIN INIT INFO
# Provides:          bleh
# Required-Start:    $remote_fs $syslog $network
# Required-Stop:     $remote_fs $syslog $network
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Start daemon at boot time
# Description:       Enable service provided by daemon.
### END INIT INFO


# Carry out specific functions when asked to by the system
case "$1" in
  start)
    cd //opt/bleh
    attrf=.gatewayattributes

    if [ ! -z "$1" ]
    then
  echo "[gateway]" >> $attrf
    echo "activationKey = $1" >> $attrf
fi

./bleh1 -n &
./bleh2 &
python bleh3 &

    ;;
  stop)
cd //opt/bleh
/usr/bin/pkill -f ./bleh1 -n
    /usr/bin/pkill -f bleh3
    kill -9 $(pidof bleh2)
    rm -rf logs
    ;;

该脚本的确在运行时启动了三个进程,但是由于某种原因,我实际上无法使用启动/停止命令,例如sudo/etc/init.d bleh.sh stop.

This script does start the three processes at runtime, but for some reason I cannot actually use the start/stop commands, as in sudo /etc/init.d bleh.sh stop.

更大的问题是使用以下命令删除此软件包: sudo dpkg -r bleh

An even bigger issue is that removing this package using the command: sudo dpkg -r bleh

实际上并没有停止这三个进程,它只是尝试删除我在opt文件夹中安装的bleh目录.另外,我的bleh目录中有一个文件夹没有被删除,它给了我警告: 去除污点... dpkg:警告:删除bleh时,目录'/opt/bleh/logs'不为空,因此不会删除.

Does not actually stop the three processes, it only tries to remove the bleh directory I installed in my opt folder. Also, I have a folder inside my bleh directory which does not get removed, it gives me a warning stating: Removing bleh ... dpkg: warning: while removing bleh, directory '/opt/bleh/logs' not empty so not removed.

除非您具有SU特权,否则该日志目录中的文件均为只读,但是我在该dpkg -r命令上调用sudo时,我看不出会有什么问题.

The files inside of that logs directory are read-only unless you have SU priviledges, but I don't see how that should be a problem as I am calling sudo on that dpkg -r command.

如果我再次运行sudo dpkg -r bleh,它表明没有已安装的软件包匹配bleh,这意味着它认为它已经成功删除了已安装的软件包,即使存在该现有的logs目录以及三个仍在运行的进程.

If I run sudo dpkg -r bleh again, it states there's no installed package matching bleh, meaning it thinks it has successfully removed the installed package, even with that exisiting logs directory and the three processes which are still running.

对不起,我知道这很长一段时间,但是我真的可以使用一些帮助..在此先感谢您!

Sorry, I know this was long, but I could really use some help.. thanks in advance!

推荐答案

作为推荐,请使用dh_installinit(当然,请使用debhelper构建整个软件包).默认情况下,这将添加脚本以开始和停止软件包的安装和删除.

As recommended by the Debian New Maintainer's Guide, please use dh_installinit (building your whole package with debhelper, of course). By default, this will add scripts to start and stop on package installation and removal.

辅助文件(例如配置文件)通常以purge(例如dpkg -P)状态被删除.要自己处理此问题,您需要一个deconfigure脚本.

Auxiliary files (such as configuration) are usually removed in purge (e.g. dpkg -P) state. To handle this yourself, you need a deconfigure script.

此外,最好使用start-stop-daemon代替&,这对于正确的守护进程是不够的.

Also, it is highly preferable to use start-stop-daemon instead of &, which is insufficient for proper daemonization.

这篇关于dpkg删除以停止进程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆