问题标签 [init.d]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
0 回答
458 浏览

c++ - 启动和停止包含内核线程的守护进程

我想运行一个在 openSUSE 12 上使用 POSIX 线程作为守护进程的 c++ 程序,并且能够使用基于此模板的普通 init.d 脚本作为服务启动、停止和重新启动它:http://www.novell .com/coolsolutions/feature/15380.html

然而事实证明 startproc 和 killproc 不适合处理内核线程(显然是 POSIX 线程)。我设法用 startproc 启动程序,但它没有被 killproc 识别和杀死。rc_status 在运行 startproc 时返回红色“failed”,即使程序实际已启动,并且在运行 killproc 时返回绿色“done”,即使它没有杀死进程。

有没有在 openSUSE 12 上使用 startproc/killproc 的替代方法?如果一个人用一个简单的 nohup 启动服务,那么它是如何正常停止的呢?只是杀了它?在那种情况下,获取“kill”所需的pid的好方法是什么?

0 投票
1 回答
2207 浏览

linux - 为什么我的启动脚本没有运行

根据各种教程,我完成了以下操作:

ftpserver.py创建了一个名为/home/root/

/etc/init.d/在调用中创建了一个ftpserver看起来像这样的文件“

创建后,我运行了以下命令(显然是为了使其可执行)

但它似乎没有在启动时运行。但是,如果我运行以下命令:

然后脚本运行,执行 ftpserver.py。

有趣的是,如果我尝试以ftpserver下列方式从它的目录中运行(不确定这是否相关):

它返回:

所以我不确定为什么我的脚本在启动时没有运行。

作为参考,ftpserver.py 看起来像这样:

0 投票
2 回答
75841 浏览

linux - 什么是 linux 脚本中的 start-stop-daemon?

什么是 start-stop-daemon 以及应该如何使用它?

我正在尝试使特定程序自动运行。每当系统启动时,程序都应该运行。为此,我正在/etc/init.d/现场编写脚本。

0 投票
1 回答
188 浏览

ruby-on-rails - 使用 Chef 通过 init.d 脚本重启 Mongrel 集群

我正在使用 Chef 来管理使用 Mongrel 集群运行的 Rails 应用程序的部署。

我的init.d文件很简单。这是重新启动的情况:

我可以毫无问题地service myapp restart运行root。我可以毫无问题地mongrel_rails cluster::restart运行myuser

但是,当我通过 Chef 进行部署时,tmp/pids/mongrel.port.pid文件不会被清理(导致所有未来的重新启动都失败)。

Chef 只​​是简单地执行以下操作来执行重新启动:

init.d脚本肯定会被调用,因为日志都具有预期的输出(当然,在 pid 文件上爆炸除外)。

我错过了什么?

0 投票
2 回答
263 浏览

linux - 存储正在被另一个脚本调用的脚本的 PID

我是一个使用 shell 脚本的新手,一直在尝试编写一些脚本并让我的简单应用程序运行。虽然我可以启动应用程序,但我无法停止或重新启动它,因为它存储了脚本本身的 PID,而我需要存储被调用脚本的 PID。这是我正在运行以获取 PID 的脚本:

使用 start 命令调用此脚本后,它会显示 PID,在这种情况下假设为 3,ps 输出如下所示:

因为我将 PID 存储为 3,然后我尝试停止应用程序,但它失败了,因为我想停止的应用程序有 7,而不是 3

任何人都可以帮助我脚本的哪一部分破坏了预期的 PID?

0 投票
3 回答
2209 浏览

linux - 如何检查启动时是否调用了 init 脚本?

我在 FreeBSD 上有一个初始化脚本。该脚本在启动时由 rc.d 调用。我想做的是检查这个脚本是在启动时调用还是由用户手动调用。如何在此脚本中进行此检查。可能吗?感谢您的任何帮助...

请注意,我的问题对 FreeBSD 有效,但我还添加了 linux 标签,以防可能对 linux 应用相同的解决方案

0 投票
1 回答
5194 浏览

service - Apache init.d 脚本

我有以下脚本在我的 debian 7 中启动、停止、重新启动 apache2

当我将脚本添加到 update-rc.d 时,我看到以下警告:

但是我已经在脚本中添加了Required-Stop 和 Default-Stop。

有谁知道如何解决这个问题?

0 投票
1 回答
1683 浏览

unix - Unix 故障排除,缺少 /etc/init.d 文件

我正在阅读有关守护 php 脚本的教程。当我运行以下 Unix 命令时:

我得到以下输出:

我查看了我的文件系统,没有 /etc/init.d 文件。谁能告诉我这是什么以及在哪里获得它?还有那个文件的缺失是什么导致了另一个错误?

0 投票
2 回答
4544 浏览

django - 未找到守护 celery 进程 celeryd-multi

我正在尝试为在 virtualenv 中运行的 django 守护进程。我将 celeryd 文件从https://github.com/celery/celery/tree/master/extra/generic-init.d复制 到 /etc/init.d/

然后我创建了一个配置文件,其内容位于http://ask.github.io/celery/cookbook/daemonizing.html#example-django-configuration-using-virtualenv并将其保存为 /etc/default/celeryd

这是我的 /etc/default/celeryd:

当我运行时:

它失败并出现以下错误:

celeryd-multi start w1 --uid=celery --gid=celery --workdir=/home/manu/location/to/project/ --pidfile=/var/run/celery/%n.pid --logfile=/ var/log/celery/%n.log --loglevel=INFO --cmd=-m celery.bin.celeryd_detach --verbose --fake --time-limit=300 --concurrency=8 /etc/init.d /celeryd: 140: /etc/init.d/celeryd: celeryd-multi: 未找到

我可以看到它无法找到 celeryd_multi。奇怪的是,跑步

/path/to/project_env/bin/python /path/to/manage.py celeryd_multi

显示 celeryd-multi 可用。

[更新 - 用@Daniel Roseman 的输入更正我的启动命令]

现在,当我运行时:

sh -x /etc/init.d/celeryd start

这是我看到的输出:

/path/to/.virtualenvs/virtenv/bin/python /path/to/project//manage.py celeryd_detach --time-limit=300 --concurrency=8 --gid=celery --broker=amqp:// :@localhost:5672// -n w1.ubuntu-12-10 --logfile=/var/log/celery/w1.log --loglevel=INFO --uid=celery --pidfile=/var/run/celery /w1.pid --workdir=/path/to/project/

好的

+ 睡眠 5

+ 退出 0

我在这里想念什么?请帮忙!

0 投票
1 回答
357 浏览

python - /init.d/function + python version

I am trying to daemonize celery and celerybeat. I have downloaded the celeryd and celeybeat files from github and placed them in /etc/init.d/ (celery and celerybeat) with the corresponding config files under /etc/default/.

My problem is that when I run these two files, celeryd and celerybeat use system python (2.4), and as a result cannot find other installed applications under python 2.7. Python 2.7 is in ~/.bashrc and /.bash_profile files, so I do not have any problems running other applications, except when workers fail to work. When I run python ...../manage.py celery ( with all options) everything works like a charm.

Please let me know how I can force /init.d/function to run python2.7.

I have tried to implement #! /bin/sh python, but it does not work.