Skip to content

Instantly share code, notes, and snippets.

@erikthered
Created August 28, 2012 16:58
Show Gist options
  • Save erikthered/3500628 to your computer and use it in GitHub Desktop.
Save erikthered/3500628 to your computer and use it in GitHub Desktop.
Hubot Upstart script with logging
# hubot
description "Hubot chat bot"
start on filesystem or runlevel [2345]
stop on runlevel [!2345]
# Path to Hubot installation
env HUBOT_DIR='/opt/hubot/'
env HUBOT='bin/hubot'
# Make sure to choose the appropriate adapter
env ADAPTER='talker'
env LOGFILE='/var/log/hubot/hubot.log'
# Name (and local user) to run Hubot as
env HUBOT_USER='hubot'
# httpd listen port
env PORT='5100'
# Talker-specific environment variables
# Remember to setup the correct variables for your chosen adapter
env HUBOT_TALKER_TOKEN='your_api_key'
env HUBOT_TALKER_ROOMS='your_room'
# Keep the process alive, limit to 5 restarts in 60s
respawn
respawn limit 5 60
exec start-stop-daemon --start --chuid ${HUBOT_USER} --chdir ${HUBOT_DIR} \
--exec ${HUBOT_DIR}${HUBOT} -- --name ${HUBOT_USER} --adapter ${ADAPTER} \
2>&1 | ( while read line; do echo "$(date): ${line}"; done ) > ${LOGFILE}
@erikthered
Copy link
Author

Sometimes my logs get filled with binary data after running for some time. If anyone knows what is causing this, let me know.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment