have created a new systemd service for botpress If I do
systemctl start botpress.service
it Starts all the botpress stuff then immeaditly runs the ExecStop stuff. Systemctl starts fine if I remove ExecStop=.......
the script being called works just fine.
cat /etc/systemd/system/botpress.service
[Unit]
Description=botpess
After=docker.service
[Service]
Type=simple
TimeoutStartSec=5s
ExecStartPre=/bin/bash -c 'echo ">>>>>>>>>>> pre-starting botpress <<<<<<<<<<<<<<<"'
ExecStart=/etc/systemd/system/botpress.initd start
ExecStartPost=/bin/bash -c 'echo ">>>>>>>>>>> post-starting botpress <<<<<<<<<<<<<<<"'
ExecStop=/etc/systemd/system/botpress.initd stop
ExecStopPost=/bin/bash -c 'echo ">>>>>>>>>>> post-stopping botpress <<<<<<<<<<<<<<<"'
[Install]
WantedBy=multi-user.target
I can put put the botpress.initd script in /etc/init.d and get systemctl to stop and start but will not restart at reboot. all I want to do is just call a simple script that can start and stop on demand and enable at reboot
cat botpress.initd
#! /bin/bash -x
### BEGIN INIT INFO
# Provides: my-service-name
# Required-Start: $all
# Required-Stop:
# Default-Start: 2 3 4 5
# Default-Stop:
# Short-Description: your description here
### END INIT INFO
BOTPRESS_COMPOSE_HOME="/home/pcooke/tmp/botpress/examples/docker-compose/"
COMPOSE_YAML="docker-compose-pro-nginx.yaml"
# Default-Start: 2 3 4 5
#OPTIONS="--verbose"
start() {
echo "starting botpress"
/usr/local/bin/docker-compose ${OPTIONS} -f ${COMPOSE_YAML} up -d --build
}
stop() {
echo "stopping botpress"
/usr/local/bin/docker-compose ${OPTIONS} -f ${COMPOSE_YAML} down
}
cd ${BOTPRESS_COMPOSE_HOME}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
start
;;
*)
echo $"Usage: $0 {start|stop|restart}"
exit 1
esac
root@pcooke-XPS-13-9370:/etc/systemd/system# journalctl -xe
Apr 07 21:20:50 pcooke-XPS-13-9370 botpress.initd[4029]: [263B blob data]
Apr 07 21:20:50 pcooke-XPS-13-9370 botpress.initd[4029]: Removing botpress-server ...
Apr 07 21:20:50 pcooke-XPS-13-9370 botpress.initd[4029]: Removing redis ...
Apr 07 21:20:50 pcooke-XPS-13-9370 botpress.initd[4029]: Removing botpress-lang ...
Apr 07 21:20:50 pcooke-XPS-13-9370 botpress.initd[4029]: Removing postgres ...
Apr 07 21:20:50 pcooke-XPS-13-9370 botpress.initd[4029]: [274B blob data]
Apr 07 21:20:50 pcooke-XPS-13-9370 avahi-daemon[817]: Interface br-e6bd415385a8.IPv6 no longer relevant for mDNS.
Apr 07 21:20:50 pcooke-XPS-13-9370 avahi-daemon[817]: Leaving mDNS multicast group on interface br-e6bd415385a8.IPv6 with address fe80::42:9fff:fe45:b457.
Apr 07 21:20:50 pcooke-XPS-13-9370 avahi-daemon[817]: Interface br-e6bd415385a8.IPv4 no longer relevant for mDNS.
Apr 07 21:20:50 pcooke-XPS-13-9370 avahi-daemon[817]: Leaving mDNS multicast group on interface br-e6bd415385a8.IPv4 with address 172.27.0.1.
Apr 07 21:20:50 pcooke-XPS-13-9370 avahi-daemon[817]: Withdrawing address record for fe80::42:9fff:fe45:b457 on br-e6bd415385a8.
Apr 07 21:20:50 pcooke-XPS-13-9370 avahi-daemon[817]: Withdrawing address record for 172.27.0.1 on br-e6bd415385a8.
Apr 07 21:20:50 pcooke-XPS-13-9370 NetworkManager[849]: <info> [1586319650.5374] device (br-e6bd415385a8): state change: activated -> unmanaged (reason 'unmanaged', sys-iface-state: 'removed')
Apr 07 21:20:50 pcooke-XPS-13-9370 dbus-daemon[824]: [system] Activating via systemd: service name='org.freedesktop.nm_dispatcher' unit='dbus-org.freedesktop.nm-dispatcher.service' requested by ':1.10' (u
Apr 07 21:20:50 pcooke-XPS-13-9370 gnome-shell[2943]: Removing a network device that was not added
Apr 07 21:20:50 pcooke-XPS-13-9370 systemd[1]: Starting Network Manager Script Dispatcher Service...
-- Subject: Unit NetworkManager-dispatcher.service has begun start-up
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
--
-- Unit NetworkManager-dispatcher.service has begun starting up.
Apr 07 21:20:50 pcooke-XPS-13-9370 gnome-shell[1161]: Removing a network device that was not added
Apr 07 21:20:50 pcooke-XPS-13-9370 dbus-daemon[824]: [system] Successfully activated service 'org.freedesktop.nm_dispatcher'
Apr 07 21:20:50 pcooke-XPS-13-9370 systemd[1]: Started Network Manager Script Dispatcher Service.
-- Subject: Unit NetworkManager-dispatcher.service has finished start-up
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
--
-- Unit NetworkManager-dispatcher.service has finished starting up.
--
-- The start-up result is RESULT.
Apr 07 21:20:50 pcooke-XPS-13-9370 nm-dispatcher[4557]: req:1 'down' [br-e6bd415385a8]: new request (2 scripts)
Apr 07 21:20:50 pcooke-XPS-13-9370 nm-dispatcher[4557]: req:1 'down' [br-e6bd415385a8]: start running ordered scripts...
Apr 07 21:20:50 pcooke-XPS-13-9370 NetworkManager[849]: <info> [1586319650.5626] devices removed (path: /sys/devices/virtual/net/br-e6bd415385a8, iface: br-e6bd415385a8)
Apr 07 21:20:50 pcooke-XPS-13-9370 systemd-resolved[641]: Server returned error NXDOMAIN, mitigating potential DNS violation DVE-2018-0001, retrying transaction with reduced feature level UDP.
Apr 07 21:20:50 pcooke-XPS-13-9370 bash[4641]: >>>>>>>>>>> post-stopping botpress <<<<<<<<<<<<<<<
Apr 07 21:20:51 pcooke-XPS-13-9370 systemd-resolved[641]: Server returned error NXDOMAIN, mitigating potential DNS violation DVE-2018-0001, retrying transaction with reduced feature level UDP.
Apr 07 21:20:51 pcooke-XPS-13-9370 systemd-resolved[641]: Server returned error NXDOMAIN, mitigating potential DNS violation DVE-2018-0001, retrying transaction with reduced feature level UDP.
Apr 07 21:20:51 pcooke-XPS-13-9370 systemd-resolved[641]: Server returned error NXDOMAIN, mitigating potential DNS violation DVE-2018-0001, retrying transaction with reduced feature level UDP.
Apr 07 21:20:51 pcooke-XPS-13-9370 systemd-resolved[641]: Server returned error NXDOMAIN, mitigating potential DNS violation DVE-2018-0001, retrying transaction with reduced feature level UDP.
Apr 07 21:20:51 pcooke-XPS-13-9370 systemd-resolved[641]: Server returned error NXDOMAIN, mitigating potential DNS violation DVE-2018-0001, retrying transaction with reduced feature level UDP.
Apr 07 21:20:51 pcooke-XPS-13-9370 systemd-resolved[641]: Server returned error NXDOMAIN, mitigating potential DNS violation DVE-2018-0001, retrying transaction with reduced feature level UDP.
Apr 07 21:20:53 pcooke-XPS-13-9370 systemd-resolved[641]: Server returned error NXDOMAIN, mitigating potential DNS violation DVE-2018-0001, retrying transaction with reduced fe
/////
after changing type to onshot and restarting
root@pcoo/ke-XPS-13-9370:/etc/systemd/system# systemctl start botpress
Job for botpress.service failed because a timeout was exceeded.
See "systemctl status botpress.service" and "journalctl -xe" for details.
systemctl status botpress
● botpress.service - botpess
Loaded: loaded (/etc/systemd/system/botpress.service; disabled; vendor preset: enabled)
Active: failed (Result: timeout) since Wed 2020-04-08 19:14:33 PDT; 5min ago
Process: 11561 ExecStopPost=/bin/bash -c echo ">>>>>>>>>>> post-stopping botpress <<<<<<<<<<<<<<<" (code=exited, status=0/SUCCESS)
Process: 11026 ExecStart=/etc/systemd/system/botpress.initd start (code=killed, signal=TERM)
Process: 11025 ExecStartPre=/bin/bash -c echo ">>>>>>>>>>> pre-starting botpress <<<<<<<<<<<<<<<" (code=exited, status=0/SUCCESS)
Main PID: 11026 (code=killed, signal=TERM)
Apr 08 19:14:30 pcooke-XPS-13-9370 botpress.initd[11026]: Successfully tagged docker-compose_nginx:latest
Apr 08 19:14:30 pcooke-XPS-13-9370 botpress.initd[11026]: Creating postgres ...
Apr 08 19:14:30 pcooke-XPS-13-9370 botpress.initd[11026]: Creating redis ...
Apr 08 19:14:30 pcooke-XPS-13-9370 botpress.initd[11026]: Creating botpress-lang ...
Apr 08 19:14:33 pcooke-XPS-13-9370 systemd[1]: botpress.service: Start operation timed out. Terminating.
Apr 08 19:14:33 pcooke-XPS-13-9370 systemd[1]: botpress.service: Main process exited, code=killed, status=15/TERM
Apr 08 19:14:33 pcooke-XPS-13-9370 botpress.initd[11026]: [90B blob data]
Apr 08 19:14:33 pcooke-XPS-13-9370 bash[11561]: >>>>>>>>>>> post-stopping botpress <<<<<<<<<<<<<<<
Apr 08 19:14:33 pcooke-XPS-13-9370 systemd[1]: botpress.service: Failed with result 'timeout'.
Apr 08 19:14:33 pcooke-XPS-13-9370 systemd[1]: Failed to start botpess.
new journalctl -xe
journalctl -xe
Apr 08 19:14:32 pcooke-XPS-13-9370 systemd-resolved[641]: Server returned error NXDOMAIN, mitigating potential DNS violation DVE-2018-0001, retrying transaction with reduced feature level UDP.
Apr 08 19:14:32 pcooke-XPS-13-9370 systemd-resolved[641]: Server returned error NXDOMAIN, mitigating potential DNS violation DVE-2018-0001, retrying transaction with reduced feature level UDP.
Apr 08 19:14:32 pcooke-XPS-13-9370 kernel: eth0: renamed from vethfbd729e
Apr 08 19:14:32 pcooke-XPS-13-9370 NetworkManager[849]: <info> [1586398472.3620] devices removed (path: /sys/devices/virtual/net/vethfbd729e, iface: vethfbd729e)
Apr 08 19:14:32 pcooke-XPS-13-9370 kernel: IPv6: ADDRCONF(NETDEV_CHANGE): vethaec5c13: link becomes ready
Apr 08 19:14:32 pcooke-XPS-13-9370 kernel: br-83455e030a4d: port 1(vethaec5c13) entered blocking state
Apr 08 19:14:32 pcooke-XPS-13-9370 kernel: br-83455e030a4d: port 1(vethaec5c13) entered forwarding state
Apr 08 19:14:32 pcooke-XPS-13-9370 NetworkManager[849]: <info> [1586398472.3647] device (vethaec5c13): carrier: link connected
Apr 08 19:14:32 pcooke-XPS-13-9370 gnome-shell[2943]: Removing a network device that was not added
Apr 08 19:14:32 pcooke-XPS-13-9370 gnome-shell[1161]: Removing a network device that was not added
Apr 08 19:14:32 pcooke-XPS-13-9370 avahi-daemon[817]: Joining mDNS multicast group on interface br-83455e030a4d.IPv6 with address fe80::42:76ff:fe65:828.
Apr 08 19:14:32 pcooke-XPS-13-9370 avahi-daemon[817]: New relevant interface br-83455e030a4d.IPv6 for mDNS.
Apr 08 19:14:32 pcooke-XPS-13-9370 avahi-daemon[817]: Registering new address record for fe80::42:76ff:fe65:828 on br-83455e030a4d.*.
Apr 08 19:14:33 pcooke-XPS-13-9370 avahi-daemon[817]: Joining mDNS multicast group on interface veth9ba683a.IPv6 with address fe80::877:c1ff:fe8d:4ccf.
Apr 08 19:14:33 pcooke-XPS-13-9370 avahi-daemon[817]: New relevant interface veth9ba683a.IPv6 for mDNS.
Apr 08 19:14:33 pcooke-XPS-13-9370 avahi-daemon[817]: Registering new address record for fe80::877:c1ff:fe8d:4ccf on veth9ba683a.*.
Apr 08 19:14:33 pcooke-XPS-13-9370 kernel: eth0: renamed from vethbde55a8
Apr 08 19:14:33 pcooke-XPS-13-9370 NetworkManager[849]: <info> [1586398473.3297] devices removed (path: /sys/devices/virtual/net/vethbde55a8, iface: vethbde55a8)
Apr 08 19:14:33 pcooke-XPS-13-9370 kernel: IPv6: ADDRCONF(NETDEV_CHANGE): veth1583c41: link becomes ready
Apr 08 19:14:33 pcooke-XPS-13-9370 kernel: br-83455e030a4d: port 3(veth1583c41) entered blocking state
Apr 08 19:14:33 pcooke-XPS-13-9370 kernel: br-83455e030a4d: port 3(veth1583c41) entered forwarding state
Apr 08 19:14:33 pcooke-XPS-13-9370 NetworkManager[849]: <info> [1586398473.3324] device (veth1583c41): carrier: link connected
Apr 08 19:14:33 pcooke-XPS-13-9370 gnome-shell[1161]: Removing a network device that was not added
Apr 08 19:14:33 pcooke-XPS-13-9370 gnome-shell[2943]: Removing a network device that was not added
Apr 08 19:14:33 pcooke-XPS-13-9370 systemd[1]: botpress.service: Start operation timed out. Terminating.
Apr 08 19:14:33 pcooke-XPS-13-9370 systemd[1]: botpress.service: Main process exited, code=killed, status=15/TERM
Apr 08 19:14:33 pcooke-XPS-13-9370 botpress.initd[11026]: [90B blob data]
Apr 08 19:14:33 pcooke-XPS-13-9370 bash[11561]: >>>>>>>>>>> post-stopping botpress <<<<<<<<<<<<<<<
Apr 08 19:14:33 pcooke-XPS-13-9370 systemd[1]: botpress.service: Failed with result 'timeout'.
Apr 08 19:14:33 pcooke-XPS-13-9370 systemd[1]: Failed to start botpess.
-- Subject: Unit botpress.service has failed
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
--
-- Unit botpress.service has failed.
--
-- The result is RESULT.
Apr 08 19:14:34 pcooke-XPS-13-9370 avahi-daemon[817]: Joining mDNS multicast group on interface vethaec5c13.IPv6 with address fe80::60f4:dfff:fe0a:ff72.
Apr 08 19:14:34 pcooke-XPS-13-9370 avahi-daemon[817]: New relevant interface vethaec5c13.IPv6 for mDNS.
Apr 08 19:14:34 pcooke-XPS-13-9370 avahi-daemon[817]: Registering new address record for fe80::60f4:dfff:fe0a:ff72 on vethaec5c13.*.
Apr 08 19:14:34 pcooke-XPS-13-9370 avahi-daemon[817]: Joining mDNS multicast group on interface veth1583c41.IPv6 with address fe80::d4ce:bdff:fedc:6e74.
Apr 08 19:14:34 pcooke-XPS-13-9370 avahi-daemon[817]: New relevant interface veth1583c41.IPv6 for mDNS.
Apr 08 19:14:34 pcooke-XPS-13-9370 avahi-daemon[817]: Registering new address record for fe80::d4ce:bdff:fedc:6e74 on veth1583c41.*.
Apr 08 19:14:37 pcooke-XPS-13-9370 systemd-resolved[641]: Server returned error NXDOMAIN, mitigating potential DNS violation DVE-2018-0001, retrying transaction with reduced feature level UDP.
Apr 08 19:14:37 pcooke-XPS-13-9370 systemd-resolved[641]: Server returned error NXDOMAIN, mitigating potential DNS violation DVE-2018-0001, retrying transaction with reduced feature level UDP.
Apr 08 19:14:37 pcooke-XPS-13-9370 systemd-resolved[641]: Server returned error NXDOMAIN, mitigating potential DNS violation DVE-2018-0001, retrying transaction with reduced feature level UDP.
Apr 08 19:14:37 pcooke-XPS-13-9370 systemd-resolved[641]: Server returned error NXDOMAIN, mitigating potential DNS violation DVE-2018-0001, retrying transaction with reduced feature level UDP.
Apr 08 19:14:37 pcooke-XPS-13-9370 systemd-resolved[641]: Server returned error NXDOMAIN, mitigating potential DNS violation DVE-2018-0001, retrying transaction with reduced feature level UDP.
Apr 08 19:14:37 pcooke-XPS-13-9370 systemd-resolved[641]: Server returned error NXDOMAIN, mitigating potential DNS violation DVE-2018-0001, retrying transaction with reduced feature level UDP.
Apr 08 19:17:01 pcooke-XPS-13-9370 CRON[11653]: pam_unix(cron:session): session opened for user root by (uid=0)
Apr 08 19:17:01 pcooke-XPS-13-9370 CRON[11654]: (root) CMD ( cd / && run-parts --report /etc/cron.hourly)
Apr 08 19:17:01 pcooke-XPS-13-9370 CRON[11653]: pam_unix(cron:session): session closed for user root
what is interesting is: after enabling botpress and a reboot now all but nginx container starts
systemctl status botpress
● botpress.service - botpess
Loaded: loaded (/etc/systemd/system/botpress.service; enabled; vendor preset: enabled)
Active: failed (Result: timeout) since Wed 2020-04-08 19:27:24 PDT; 2min 52s ago
Process: 2490 ExecStopPost=/bin/bash -c echo ">>>>>>>>>>> post-stopping botpress <<<<<<<<<<<<<<<" (code=exited, status=0/SUCCESS)
Process: 1677 ExecStart=/etc/systemd/system/botpress.initd start (code=killed, signal=TERM)
Process: 1676 ExecStartPre=/bin/bash -c echo ">>>>>>>>>>> pre-starting botpress <<<<<<<<<<<<<<<" (code=exited, status=0/SUCCESS)
Main PID: 1677 (code=killed, signal=TERM)
Apr 08 19:27:20 pcooke-XPS-13-9370 botpress.initd[1677]: Successfully tagged docker-compose_nginx:latest
Apr 08 19:27:20 pcooke-XPS-13-9370 botpress.initd[1677]: Starting botpress-lang ...
Apr 08 19:27:20 pcooke-XPS-13-9370 botpress.initd[1677]: Starting redis ...
Apr 08 19:27:20 pcooke-XPS-13-9370 botpress.initd[1677]: Starting postgres ...
Apr 08 19:27:23 pcooke-XPS-13-9370 botpress.initd[1677]: [163B blob data]
Apr 08 19:27:24 pcooke-XPS-13-9370 systemd[1]: botpress.service: Start operation timed out. Terminating.
Apr 08 19:27:24 pcooke-XPS-13-9370 systemd[1]: botpress.service: Main process exited, code=killed, status=15/TERM
Apr 08 19:27:24 pcooke-XPS-13-9370 bash[2490]: >>>>>>>>>>> post-stopping botpress <<<<<<<<<<<<<<<
Apr 08 19:27:24 pcooke-XPS-13-9370 systemd[1]: botpress.service: Failed with result 'timeout'.
Apr 08 19:27:24 pcooke-XPS-13-9370 systemd[1]: Failed to start botpess.
when I just have ExecStart I get no mention of tagging NGINX. Here is my compse file.
cat docker-compose-pro-nginx.yaml
version: '3.7'
services:
botpress:
build:
context: ./botpress
dockerfile: Dockerfile
image: botpress-server
container_name: botpress-server
command: bash -c "export AUTO_MIGRATE=true; ./bp --auto-update"
expose:
- 3000
environment:
- DATABASE_URL=postgres://postgres:secretpw@postgres:5435/botpress_db
- REDIS_URL=redis://redis:6379?password=redisPassword
- BP_MODULE_NLU_DUCKLINGURL=http://botpress_lang:8000
- BP_MODULE_NLU_LANGUAGESOURCES=[{"endpoint":"http://botpress_lang:3100"}]
- EXTERNAL_URL=https://botpressdev.sf.frb.org
- CLUSTER_ENABLED=true
- PRO_ENABLED=true
- BP_PRODUCTION=true
- BPFS_STORAGE=database
- BP_LICENSE_KEY=123456789
depends_on:
- botpress_lang
- postgres
- redis
volumes:
- /opt/botpress-data/botpress:/botpress/data
botpress_lang:
build:
context: ./botpress
dockerfile: Dockerfile
image: botpress-lang
container_name: botpress-lang
command: bash -c "./duckling -p 8000 & ./bp lang --langDir /botpress/lang --port 3100"
expose:
- 3100
- 8000
volumes:
- /opt/botpress-data/language:/botpress/lang
postgres:
image: postgres:11.2-alpine
expose:
- 5435
container_name: postgres
environment:
PGPORT: 5435
POSTGRES_DB: botpress_db
POSTGRES_PASSWORD: secretpw
POSTGRES_USER: postgres
volumes:
- /opt/botpress-data/postgres/data:/var/lib/postgresql/data
redis:
image: redis:5.0.5-alpine
expose:
- 6379
container_name: redis
command: redis-server --requirepass redisPassword
volumes:
- redisdata:/data
nginx:
container_name: nginx
build: ./nginx
ports:
- 80:80
command: nginx -g 'daemon off';
depends_on:
- botpress
volumes:
redisdata:
It sounds as though it may be a "one shot" command.
What that means is that you start the process with systemd then as soon as it is up and running systemd takes over responsibility for it and runs it in the background. The process ID was only needed to start it, not to keep it running.
To test, please run and show the outcome here, of :
systemctl status botpress.service
- amend "botpress" if that is not the actual name of the package.To start the process as a systemd unit at boot, run
sytemctl enable botpress.service
at anytime before the next reboot. Now would be good.well well I feel like the fresh college grad with no experience.
Talking with vendor all I needed was to add "restart: always" to my compose file and let docker do the rest.