Skip to content

Commit b73f595

Browse files
exanedevfake
authored andcommitted
Update worker install script (#111)
1 parent b23dca4 commit b73f595

File tree

6 files changed

+42
-126
lines changed

6 files changed

+42
-126
lines changed

README.md

+7-4
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,13 @@ To import or refresh any of your entries you need to have at least one worker ru
7272
# spawn a single worker
7373
php artisan queue:work --daemon --tries=3
7474

75-
# or
75+
# Alternatively install it as a systemctl service:
7676

77-
./bin/start_queue 4 # number determines the amount of workers, defaults to 1
78-
./bin/stop_queue # stop all workers
77+
# The script uses the current directory as Flox root path. To override
78+
# use the first argument and set a new absolute Flox (root) path.
79+
# A second argument takes the php path (defaults to /usr/bin)
80+
bash ./bin/install_worker_service.sh
81+
# bash ./bin/install_worker_service.sh $HOME/flox /custom/path/to/php/
7982
```
8083

8184
Check the [documentation](https://laravel.com/docs/5.5/queues) for more informations.
@@ -126,7 +129,7 @@ Make sure you tweak the `DATE_FORMAT_PATTERN` config in your `.env` file.
126129

127130
All titles are in english by default. You can change your language by setting `TRANSLATION` in `backend/.env`. The most commons are `DE`, `IT`, `FR`, `ES` and `RU`. You can try to use your language code.
128131

129-
This will also affect the language of you website. See in `client/resources/languages` if your language is supported. Pull requests are welcome :)
132+
This will also affect the language of you website. See in `client/resources/languages` if your language is supported. Pull requests are welcome :)
130133

131134
If there isn't a translation for your language, english will be used.
132135

bin/bootstrap.sh

-54
This file was deleted.

bin/dev_cleanup.sh

-54
This file was deleted.

bin/install_worker_service.sh

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#!/bin/bash
2+
3+
echo "Installing Flox worker as a service"
4+
5+
FLOX_PATH=${1:-$PWD}
6+
echo "Looking for Flox in path: $FLOX_PATH"
7+
8+
PHP_PATH=${2:-/usr/bin}
9+
echo "Using php binary in: $PHP_PATH"
10+
11+
mkdir -p $HOME/.config/systemd/user
12+
FILE=$HOME/.config/systemd/user/flox.service
13+
echo "Installing service in: $FILE"
14+
15+
cat > $FILE <<- EOM
16+
[Unit]
17+
Description=Flox Worker Service
18+
19+
[Service]
20+
ExecStart=$PHP_PATH/php $FLOX_PATH/backend/artisan queue:work --tries=3
21+
Restart=always
22+
23+
[Install]
24+
WantedBy=flox.target
25+
EOM
26+
27+
systemctl --user daemon-reload
28+
echo "Enabling flox.service..."
29+
systemctl --user enable flox.service
30+
echo "Starting flox.service..."
31+
systemctl --user start flox.service
32+
33+
echo "Done installing Flox service"
34+
35+
systemctl --user status flox

bin/start_queue

-10
This file was deleted.

bin/stop_queue

-4
This file was deleted.

0 commit comments

Comments
 (0)