2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

BitnamiのAutostartについて

Last updated at Posted at 2020-07-28

公式ドキュメントはあるのに詰まってしまった所を書き残しておきます。
→ Start the stack automatically on boot
※ 今回は、RedHat-like Distributions (Red Hat, Fedora Core, CentOS, Suse, …) でなく
  Debian-like Distributions (Debian, Ubuntu, …) の話です。

スクリプトの加工の仕方

流れとしては、上の記事にある通り、
Bitnamiのアプリ制御スクリプトであるところの ctlscript.sh を流用していきます。

sudo cp installdir/ctlscript.sh /etc/init.d/bitnami-APPNAME

本記事のポイントは以下の部分です。

スクリプトへ挿入せよと言われる部分
### BEGIN INIT INFO
# Provides:          bitnami-APPNAME
# Required-Start:    $remote_fs $syslog
# Required-Stop:     $remote_fs $syslog
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Start daemon at boot time
# Description:       Enable services provided by daemon.
### END INIT INFO

これを #!/bin/bash の後に追記する様にしてください。
もし #!/bin/bash より先に記述してしまうと、
以下の様に、フォーマットエラーでOS起動時の実行に失敗してしまいます。

$ systemctl status bitnami-APPs.service
● bitnami-APPs.service - LSB: Start daemon at boot time
     Loaded: loaded (/etc/init.d/bitnami-APPs; generated)
     Active: failed (Result: exit-code) since Tue 2020-07-28 23:21:13 JST; 1min 13s ago
       Docs: man:systemd-sysv-generator(8)
    Process: 512 ExecStart=/etc/init.d/bitnami-APPs start (code=exited, status=203/EXEC)

Jul 28 23:21:13 on20200516 systemd[1]: Starting LSB: Start daemon at boot time...
Jul 28 23:21:13 on20200516 systemd[512]: bitnami-APPs.service: Failed to execute command: Exec format error
Jul 28 23:21:13 on20200516 systemd[512]: bitnami-APPs.service: Failed at step EXEC spawning /etc/init.d/bitnami-APPs: Exec format error
Jul 28 23:21:13 on20200516 systemd[1]: bitnami-APPs.service: Control process exited, code=exited, status=203/EXEC
Jul 28 23:21:13 on20200516 systemd[1]: bitnami-APPs.service: Failed with result 'exit-code'.
Jul 28 23:21:13 on20200516 systemd[1]: Failed to start LSB: Start daemon at boot time.

正しく追記した場合は以下の様に正常に自動起動に成功します。

$ systemctl status bitnami-APPs.service
● bitnami-APPs.service - LSB: Start daemon at boot time
     Loaded: loaded (/etc/init.d/bitnami-APPs; generated)
     Active: active (running) since Tue 2020-07-28 23:24:56 JST; 41s ago
       Docs: man:systemd-sysv-generator(8)
    Process: 514 ExecStart=/etc/init.d/bitnami-APPs start (code=exited, status=0/SUCCESS)
      Tasks: 46 (limit: 682)
     Memory: 283.5M
     CGroup: /system.slice/bitnami-APPs.service
             ├─ 569 /bin/sh /opt/bitnami/mysql/bin/mysqld_safe --defaults-file=/opt/bitnami/mysql/my.cnf --mysqld=mysqld.bin --socket=/opt/bitnami/mysql/tmp/my>
             ├─ 899 /opt/bitnami/mysql/bin/mysqld.bin --defaults-file=/opt/bitnami/mysql/my.cnf --basedir=/opt/bitnami/mysql --datadir=/opt/bitnami/mysql/data >
             ├─1155 /opt/bitnami/apache2/bin/httpd.bin -f /opt/bitnami/apache2/conf/httpd.conf
             ├─1169 /opt/bitnami/apache2/bin/httpd.bin -f /opt/bitnami/apache2/conf/httpd.conf
             ├─1170 /opt/bitnami/apache2/bin/httpd.bin -f /opt/bitnami/apache2/conf/httpd.conf
             ├─1171 /opt/bitnami/apache2/bin/httpd.bin -f /opt/bitnami/apache2/conf/httpd.conf
             ├─1172 /opt/bitnami/apache2/bin/httpd.bin -f /opt/bitnami/apache2/conf/httpd.conf
             └─1173 /opt/bitnami/apache2/bin/httpd.bin -f /opt/bitnami/apache2/conf/httpd.conf

Jul 28 23:24:18 on20200516 systemd[1]: Starting LSB: Start daemon at boot time...
Jul 28 23:24:48 on20200516 bitnami-APPs[567]: /opt/bitnami/mysql/scripts/ctl.sh : mysql  started at port 3306
Jul 28 23:24:56 on20200516 bitnami-APPs[1151]: Syntax OK
Jul 28 23:24:56 on20200516 bitnami-APPs[1150]: /opt/bitnami/apache2/scripts/ctl.sh : httpd started at port 80
Jul 28 23:24:56 on20200516 systemd[1]: Started LSB: Start daemon at boot time.
2
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?