私はJavaアプリを持っています-Java、Ruby、Pythonなどであるかどうかに関係なく、ここでの答えは同じであるはずです-devopsの人々がそれをインストールしようとすると、自動的に実行されるように配布したいと思いますデーモンとして、彼らの側にゼロ構成があります。これに対する私のインスピレーションは、Goで記述されているDockerデーモンから来ていますが、Ubuntuマシンでは自動的にデーモンとして構成されます。同じことをしたいのですが、どこから始めればいいのかわかりません。
私は次のいずれかを想像します:
deb
;の中にパッケージ化する必要があります。またはinit
/ systemd
/ upstart
/など。エンドユーザーがスクリプトを実行しなくても、何らかの形でローカルにインストールされるスクリプト。ただし、この場合、ユーザーがいくつかのinit
ようなツールのセットアップのいずれかを持っている可能性があるため、インストールするスクリプトを選択する方法がわかりません。何か案は?
Ubuntu(およびDebian)では、deb
すべてを自動化できるため、エンドユーザーの介入が不要なため、パッケージを作成するのが最善の方法です。パッケージのインストールまたはアップグレードが自動化されていない唯一のケースは、パッケージにユーザーからの入力が必要な構成オプションがある場合(主にインストール中のみ)、または構成ファイルがユーザーによって変更され、の新しいバージョンによっても変更された場合です。パッケージ(アップグレード中)。さらに、パッケージをインストール/アップグレードした後、パッケージがインストールする起動スクリプトが自動的に開始されます。
You can have multiple init
scripts be installed, and have everything still work. In the case of systemd
being installed and used on the user's computer, if there is both an init
script and a systemd
script for the same service, then the init
script is ignored and the systemd
script is used.
In terms of the packaging itself, Debian provides helper scripts that (among other things) automatically install any startup scripts you provide (I don't think upstart
is supported by their helper scripts, since this is only used on Ubuntu) and start the service. For an example of the packaging, see this debian
folder for the dump1090-mutability
package. (Disclaimer: this is my Github account) Note that the dump1090-mutability.init
file contains the init
script while the dump1090-mutability.service
file contains the systemd
script. Note that the names of these files should be package-name.init
and package-name.service
, where package-name
is the name of the binary package being created. (See man dh_systemd_enable
and man dh_systemd_start
for the systemd case.)
パッケージ化時に、これらのファイルは両方ともユーザーのシステムの適切なディレクトリに配置され、サービスが開始されます。rules
ファイルについては、自動化の恩恵を受けるために、次のようなものを用意することをお勧めします(この--with systemd
部分についてはこれを参照してください)。
#!/usr/bin/make -f
%:
dh $@ --with systemd
override_dh_auto_build:
# Specify how to build the Java files here, if there is no Makefile provided
override_dh_auto_install:
# Specify how to install the Java files here, if there is no `install` target in the Makefile. Don't worry about anything in the `debian` directory unless you need to install some icons.
override_dh_auto_build
(ソースファイルがコンパイルされてJARにパッケージ化されるoverride_dh_auto_install
場所)と(JARがインストールされる場所)に入力します。install
ターゲットがない場合は、ターゲットを削除して入力override_dh_auto_build
しoverride_dh_auto_install
ます。install
ターゲット(使用可能)がある場合は、両方のターゲットを削除します。override_dh_auto_build
して入力しoverride_dh_auto_install
ます。この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。
侵害の場合は、連絡してください[email protected]
コメントを追加