ggdgsdbsdbbb / deploy.vsh
36 lines · 29 sloc · 923 bytes · 622c5e8203f282fbc25dabf3f803b661501d35f9
Raw
1#!/usr/bin/env -S v run
2
3import os
4import term
5
6const server = 'gitly'
7const remote_path = '/var/www/gitly'
8
9fn main() {
10 println('Step 1: Syncing files...')
11 // -a: archive mode (preserves permissions, recursive, etc.)
12 // -v: verbose
13 // -z: compress
14 exec_safe('rsync -avz src translations ${server}:${remote_path}/')
15
16 println('\nStep 2: Remote compilation and restart...')
17 remote_cmds := [
18 'cd ${remote_path}',
19 '/root/v2/v -keepc -d trace_pg_error -d new_veb -d use_openssl .',
20 'sudo systemctl restart gitly',
21 ].join(' && ')
22
23 println('ssh ${server} "${remote_cmds}"')
24 exec_safe('ssh ${server} "${remote_cmds}"')
25
26 println(term.green('\nDeployment successful!'))
27}
28
29fn exec_safe(cmd string) {
30 // os.system streams output directly to stdout/stderr,
31 // which is better for seeing rsync progress and compiler errors.
32 if os.system(cmd) != 0 {
33 eprintln(term.red('\n Error executing command.'))
34 exit(1)
35 }
36}
37