use a systemd service to manage pm2, and configure rtpengine with knowledge of private and public interfaces

This commit is contained in:
Dave Horton
2020-06-07 14:54:11 -04:00
parent 342b9e79bb
commit f9196602ea
9 changed files with 18 additions and 17 deletions
@@ -14,6 +14,3 @@ sudo -u admin bash -c "pm2 install pm2-logrotate"
sudo -u admin bash -c "pm2 set pm2-logrotate:max_size 1G"
sudo -u admin bash -c "pm2 set pm2-logrotate:retain 5"
sudo -u admin bash -c "pm2 set pm2-logrotate:compress true"
# add entries to /etc/crontab to start the app on reboot
echo "@reboot admin /usr/bin/pm2 start /home/admin/apps/ecosystem.config.js" | sudo tee -a /etc/crontab
@@ -8,7 +8,9 @@ After=syslog.target network.target local-fs.target
Type=forking
ExecStartPre=/bin/sh -c 'systemctl set-environment LOCAL_IP=`curl -s http://169.254.169.254/latest/meta-data/local-ipv4`'
ExecStartPre=/bin/sh -c 'systemctl set-environment PUBLIC_IP=`curl -s http://169.254.169.254/latest/meta-data/public-ipv4`'
ExecStart=/usr/local/bin/rtpengine --interface ${LOCAL_IP}!${PUBLIC_IP} \
ExecStart=/usr/local/bin/rtpengine \
--interface private/${LOCAL_IP} \
--interface public/${LOCAL_IP}!${PUBLIC_IP} \
--listen-ng=22222 \
--listen-udp=12222 \
--listen-cli=127.0.0.1:9900 \
@@ -8,7 +8,9 @@ After=syslog.target network.target local-fs.target
Type=forking
ExecStartPre=/bin/sh -c 'systemctl set-environment LOCAL_IP=`curl -s http://169.254.169.254/latest/meta-data/local-ipv4`'
ExecStartPre=/bin/sh -c 'systemctl set-environment PUBLIC_IP=`curl -s http://169.254.169.254/latest/meta-data/public-ipv4`'
ExecStart=/usr/local/bin/rtpengine --interface ${LOCAL_IP}!${PUBLIC_IP} \
ExecStart=/usr/local/bin/rtpengine \
--interface private/${LOCAL_IP} \
--interface public/${LOCAL_IP}!${PUBLIC_IP} \
--listen-ng=22222 \
--listen-udp=12222 \
--listen-cli=127.0.0.1:9900 \
@@ -25,6 +25,3 @@ sudo -u admin bash -c "pm2 install pm2-logrotate"
sudo -u admin bash -c "pm2 set pm2-logrotate:max_size 1G"
sudo -u admin bash -c "pm2 set pm2-logrotate:retain 5"
sudo -u admin bash -c "pm2 set pm2-logrotate:compress true"
# add entries to /etc/crontab to start the app on reboot
echo "@reboot admin /usr/bin/pm2 start /home/admin/apps/ecosystem.config.js" | sudo tee -a /etc/crontab
@@ -25,6 +25,3 @@ sudo -u admin bash -c "pm2 install pm2-logrotate"
sudo -u admin bash -c "pm2 set pm2-logrotate:max_size 1G"
sudo -u admin bash -c "pm2 set pm2-logrotate:retain 5"
sudo -u admin bash -c "pm2 set pm2-logrotate:compress true"
# add entries to /etc/crontab to start everything on reboot
echo "@reboot admin /usr/bin/pm2 start /home/admin/apps/ecosystem.config.js" | sudo tee -a /etc/crontab
@@ -57,8 +57,10 @@ EOF
echo "finished writing config file"
sudo -u admin bash -c "pm2 delete /home/admin/apps/ecosystem.config.js"
sudo -u admin bash -c "pm2 start /home/admin/apps/ecosystem.config.js"
sudo env PATH=$PATH:/usr/bin /usr/lib/node_modules/pm2/bin/pm2 startup systemd -u admin --hp /home/admin
sudo -u admin bash -c "pm2 save"
sudo systemctl enable pm2-admin.service
# install datadog if a datadog api key was provided
if [ "${DATADOG_API_KEY}" ] ; then
@@ -166,9 +166,10 @@ EOF
echo "finished writing config file"
# restart everything because we've updated the ecosystem file
sudo -u admin bash -c "pm2 delete /home/admin/apps/ecosystem.config.js"
sudo -u admin bash -c "pm2 start /home/admin/apps/ecosystem.config.js"
sudo env PATH=$PATH:/usr/bin /usr/lib/node_modules/pm2/bin/pm2 startup systemd -u admin --hp /home/admin
sudo -u admin bash -c "pm2 save"
sudo systemctl enable pm2-admin.service
# install datadog if a datadog api key was provided
if [ "${DATADOG_API_KEY}" ] ; then
@@ -57,8 +57,10 @@ EOF
echo "finished writing config file"
sudo -u admin bash -c "pm2 delete /home/admin/apps/ecosystem.config.js"
sudo -u admin bash -c "pm2 start /home/admin/apps/ecosystem.config.js"
sudo env PATH=$PATH:/usr/bin /usr/lib/node_modules/pm2/bin/pm2 startup systemd -u admin --hp /home/admin
sudo -u admin bash -c "pm2 save"
sudo systemctl enable pm2-admin.service
# install datadog if a datadog api key was provided
if [ "${DATADOG_API_KEY}" ] ; then
@@ -166,9 +166,10 @@ EOF
echo "finished writing config file"
# restart everything because we've updated the ecosystem file
sudo -u admin bash -c "pm2 delete /home/admin/apps/ecosystem.config.js"
sudo -u admin bash -c "pm2 start /home/admin/apps/ecosystem.config.js"
sudo env PATH=$PATH:/usr/bin /usr/lib/node_modules/pm2/bin/pm2 startup systemd -u admin --hp /home/admin
sudo -u admin bash -c "pm2 save"
sudo systemctl enable pm2-admin.service
# install datadog if a datadog api key was provided
if [ "${DATADOG_API_KEY}" ] ; then