Skip to content
This repository was archived by the owner on May 12, 2018. It is now read-only.

Commit 7350c40

Browse files
committed
Merge pull request #102 from Wachiwi/default_config
Default file for gitlab ci runner
2 parents 65a0e1c + 85cc403 commit 7350c40

File tree

3 files changed

+50
-18
lines changed

3 files changed

+50
-18
lines changed

README.md

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -123,9 +123,15 @@ exit;
123123
cd /home/gitlab_ci_runner/gitlab-ci-runner
124124
sudo cp ./lib/support/init.d/gitlab_ci_runner /etc/init.d/gitlab-ci-runner
125125
sudo chmod +x /etc/init.d/gitlab-ci-runner
126-
sudo update-rc.d gitlab-ci-runner defaults 21
126+
sudo update-rc.d gitlab-ci-runner defaults 21
127127
```
128128

129+
### Runners default file
130+
131+
```
132+
cd /home/gitlab_ci_runner/gitlab-ci-runner
133+
sudo cp ./lib/support/init.d/gitlab_ci_runner.default.example /etc/default/gitlab_ci_runner
134+
```
129135

130136
### Run
131137

@@ -154,7 +160,7 @@ bundle exec bin/runner -C /my/runner/working/directory
154160

155161
### Update
156162

157-
In order to update the runner to a new version just go to runner directory and do next:
163+
In order to update the runner to a new version just go to runner directory and do next:
158164

159165
```bash
160166
sudo su gitlab_ci_runner
@@ -181,4 +187,3 @@ Now the runner will start to pick up builds automatically. When you are done wit
181187
## Development
182188

183189
To work on the GitLab runner we recommend you install the [GitLab Development Kit](https://gitlab.com/gitlab-org/gitlab-development-kit).
184-

lib/support/init.d/gitlab_ci_runner

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
# Default-Start: 2 3 4 5
88
# Default-Stop: 0 1 6
99
# Short-Description: GitLab CI Runner init.d script
10-
# Description: Enables automatic start of runners at boot time in the background.
10+
# Description: Enables automatic start of runners at boot time in the background.
1111
### END INIT INFO
1212

1313
APP_ROOT="/home/gitlab_ci_runner/gitlab-ci-runner"
@@ -21,6 +21,9 @@ DESC="GitLab CI runner"
2121
RUNNERS_REGISTERED=0
2222
INIT_LOG="/var/log/gitlab_ci_runner.log"
2323

24+
# Read configuration variable file if it is present
25+
test -f /etc/default/gitlab_ci_runner && . /etc/default/gitlab_ci_runner
26+
2427
check_pid() {
2528
PROCESS_ID=0
2629
[ -f $RUNNER_PID ] && PROCESS_ID=`cat $RUNNER_PID`
@@ -45,7 +48,6 @@ start() {
4548
[ ! -f $PID_PATH ] && execute "mkdir -p $PID_PATH"
4649
[ -f $RUNNER_PID ] && execute "rm -f $RUNNER_PID"
4750

48-
4951
# Check log file
5052
if [ ! -f $INIT_LOG ]; then
5153
touch $INIT_LOG
@@ -60,7 +62,7 @@ start() {
6062
stop() {
6163
check_pid
6264
echo -n "Trying to stop registered runner..."
63-
65+
6466
if [ $PROCESS_ID -gt 0 ]; then
6567
execute "cat $RUNNER_PID | xargs kill -USR2"
6668
rm -f $RUNNER_PID
@@ -84,22 +86,22 @@ fi
8486

8587
case "$1" in
8688
start)
87-
start
88-
;;
89+
start
90+
;;
8991
stop)
90-
stop
91-
;;
92+
stop
93+
;;
9294
restart)
93-
stop
94-
start
95-
;;
95+
stop
96+
start
97+
;;
9698
status)
97-
status
98-
;;
99+
status
100+
;;
99101
*)
100-
echo "Usage: sudo service gitlab_ci_runner {start|stop|restart|status}" >&2
101-
exit 1
102-
;;
102+
echo "Usage: sudo service gitlab_ci_runner {start|stop|restart|status}" >&2
103+
exit 1
104+
;;
103105
esac
104106

105107
exit 0
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Copy this lib/support/init.d/gitlab_ci_runner.default.example file to
2+
# /etc/default/gitlab_ci_runner in order for it to apply to your system.
3+
4+
# app_user defines the user that GitLab is run as.
5+
# The default is "gitlab_ci_runner".
6+
APP_USER="gitlab_ci_runner"
7+
8+
# app_root defines the folder in which gitlab and it's components are installed.
9+
# The default is "/home/$app_user/gitlab-ci-runner"
10+
APP_ROOT="/home/$APP_USER/gitlab-ci-runner"
11+
12+
# pid_path defines a folder in which the gitlab-ci-runner place its pid.
13+
# This variable is also used below to define the relevant pids for the gitlab_ci_runner components.
14+
# The default is "$app_root/tmp/pids"
15+
PID_PATH="$APP_ROOT/tmp/pids"
16+
17+
# init_log defines a file in which the runners write their log messages.
18+
# The default is "/var/log/gitlab_ci_runner.log"
19+
INIT_LOG="/var/log/gitlab_ci_runner.log"
20+
21+
# Runner Configuration
22+
23+
# runners_pid_path defines a file in which the individual runners place their pids.
24+
# The default is "$pid_path/runners.pid"
25+
RUNNERS_PID="$PID_PATH/runners.pid"

0 commit comments

Comments
 (0)