| 1 | #!/usr/bin/env -S v run |
| 2 | |
| 3 | import os |
| 4 | import term |
| 5 | |
| 6 | const server = 'gitly' |
| 7 | const remote_path = '/var/www/gitly' |
| 8 | |
| 9 | fn 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 | |
| 29 | fn 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 | |