Since PhantomJS isn't going to provide any support to run daemons out of the box, you should take care of your service by yourself. It's great that you have found /etc/init.d/skeleton
and used it to create an init script. What you describe shows that your process isn't going into background and this can be fixed by means of some wrapper. This can be start-stop-daemon
which is specific to debian-based distributions, or a separate daemon
package that can redirect stdin/stdout and handle additional situations.
Since I'm almost sure you use traditional way of writing init script, I suspect you may just add --background
to your start-stop-daemon command.
When you're done fixing your script, check you have it owned by root:root
with permissions 0755 (e.g. rwxr-xr-x
). After this, update sysvinit symlinks with the update-rc.d
command provided by Michael Hampton in his answer.
Just as a note, There are some other tools that support sending process to background and may be useful in other cases. For example, supervisor, upstart and systemd support this. Please refer to their documentation to get exact syntax. If you're going to use one of these, writing full init script is not necessary.
Sure thing, init scripts is the oldest and the most supported way of starting daemons.
Если сценарий инициализации уже существует и правильно написан, его должно быть достаточно, чтобы включить его, как любой другой сценарий инициализации:
update-rc.d phantomjs defaults
или (12.04 +)
update-rc.d phantomjs enable
(Обычно это делается по умолчанию, когда вы устанавливаете пакеты с apt-get
и его кузены ...)