Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace startup scripts with one service file #38

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 7 additions & 48 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,65 +99,24 @@ The RasPi will need the following things install so it can talk to your motors a
- `cozmo_tts`
- `google_cloud`

## Setting up your start_robot file on the Raspberry Pi
## Setting up the remotv service on the Raspberry Pi

1. Copy the `start_robot` script to your home directory.
1. Link the service file to systemctl

```sh
cp ~/remotv/scripts/start_robot ~
sudo systemctl link /home/pi/remotv/script/remotv.service
```

2. Add the startup script to the `crontab`
2. Enable the service to run at startup

```sh
crontab -e
sudo systemctl enable remotv.service
```

Note: If you accidently use the wrong editor try
3. Start the service

```sh
EDITOR=nano crontab -e
```

3. Insert the following text at the bottom

```sh
@reboot /bin/bash /home/pi/start_robot
```

Example:

```sh
# Edit this file to introduce tasks to be run by cron.
#
# Each task to run has to be defined through a single line
# indicating with different fields when the task will be run
# and what command to run for the task
#
# To define the time you can provide concrete values for
# minute (m), hour (h), day of month (dom), month (mon),
# and day of week (dow) or use '*' in these fields (for 'any').#
# Notice that tasks will be started based on the cron's system
# daemon's notion of time and timezones.
#
# Output of the crontab jobs (including errors) is sent through
# email to the user the crontab file belongs to (unless redirected).
#
# For example, you can run a backup of all your user accounts
# at 5 a.m every week with:
# 0 5 * * 1 tar -zcf /var/backups/home.tgz /home/
#
# For more information see the manual pages of crontab(5) and cron(8)
#
# m h dom mon dow command

@reboot /bin/bash /home/pi/start_robot
```

4. Now just plug in the Camera and USB Speaker and reboot

```sh
sudo reboot
sudo systemctl start remotv.service
```

# Hardware Compatibility
Expand Down
5 changes: 4 additions & 1 deletion controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ def write(self, config_file):
log.setLevel(logging.DEBUG)
console_handler=logging.StreamHandler()
console_handler.setLevel(logging.getLevelName(robot_config.get('logging', 'console_level')))
console_formatter=logging.Formatter('%(asctime)s - %(filename)s : %(message)s','%H:%M:%S')
console_formatter=logging.Formatter('%(asctime)s - %(filename)s[%(lineno)d]: %(message)s','%H:%M:%S')
console_handler.setFormatter(console_formatter)
try:
file_handler=logging.handlers.RotatingFileHandler(robot_config.get('logging', 'log_file'),
Expand Down Expand Up @@ -245,6 +245,9 @@ def handle_message(ws, message):
elif event == "ROBOT_VALIDATED":
networking.handleConnectChatChannel(data["host"])

elif event == "SEND_CHAT":
pass

else:
log.error("Unknown event type")

Expand Down
2 changes: 1 addition & 1 deletion controller.sample.conf
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ boot_message=ok
announce_ip=False

# Announces when the cloned repo is out of date and by how many commits.
annouce_out_of_date=False
announce_out_of_date=False

# Enable delayed TTS, this allows a window for moderators to remove messages
# before they get passed to TTS. Messenger must be enabled for this to function.
Expand Down
2 changes: 1 addition & 1 deletion networking.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ def setupWebSocket(robot_config, onHandleMessage):
log.info("staring websocket listen process")
startListenForWebSocket()

schedule.single_task(5, checkWebSocket)
schedule.single_task(10, checkWebSocket)

if robot_config.getboolean('misc', 'check_internet'):
#schedule a task to check internet status
Expand Down
17 changes: 17 additions & 0 deletions scripts/remo.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
[Unit]
After=network.target
Description=Remo.Tv startup script
Documentation=https://docs.remo.tv

[Install]
WantedBy=multi-user.target

[Service]
ExecStart=/usr/bin/python2 /home/pi/remotv/controller.py
Restart=on-failure
RestartSec=1
StartLimitBurst=5
StartLimitInterval=60
SyslogIdentifier=remo-controller
Type=simple
WorkingDirectory=/home/pi/remotv