Skip to content

Commit d343a37

Browse files
committed
deploy.vsh
1 parent 73a6a15 commit d343a37

File tree

4 files changed

+42
-5
lines changed

4 files changed

+42
-5
lines changed

deploy.vsh

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
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+
'v -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+

src/main.v

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@ fn main() {
2222
// vweb.run_at(new_app()!, http_port)
2323

2424
veb.run_at[App, Context](mut app,
25-
port: http_port
26-
family: .ip
27-
timeout_in_seconds: 5
28-
benchmark_page_generation: true
25+
port: http_port
26+
family: .ip
27+
timeout_in_seconds: 5
28+
// benchmark_page_generation: true
2929
) or { panic(err) }
3030
}
3131

src/repo_routes.v

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ pub fn (mut app App) handle_new_repo(mut ctx Context, name string, clone_url str
259259
// println(time.since(t))
260260
}
261261
app.add_repo(new_repo) or {
262-
ctx.error('There was an error while adding the repo')
262+
ctx.error('There was an error while adding the repo ${err}')
263263
return app.new(mut ctx)
264264
}
265265
new_repo2 := app.find_repo_by_name_and_user_id(new_repo.name, ctx.user.id) or {
47.7 KB
Loading

0 commit comments

Comments
 (0)