Skip to content

Commit

Permalink
Merge pull request #183 from EpicsDAO/debug
Browse files Browse the repository at this point in the history
Update - solv restart
  • Loading branch information
POPPIN-FUMI authored Jun 7, 2024
2 parents 06245be + ca2fdec commit 891c78d
Show file tree
Hide file tree
Showing 9 changed files with 45 additions and 96 deletions.
26 changes: 26 additions & 0 deletions .changeset/sour-months-begin.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
---
'@epics-dao/solv': patch
---

Update - solv restart

```bash
$ solv restart
```

This command will do this command below;

```bash
solana-validator --ledger /mnt/ledger exit --max-delinquent-stake 5
```

You can change `--max-delinquent-stake` value as you edit the `solv` configuration file.

`/home/solv/solv.config.json`

```json
{
,...
"maxDelinquentStake": 5
}
```
9 changes: 9 additions & 0 deletions packages/solv/src/cli/get/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { showConfig } from './showConfig'
import { ConfigParams } from '@/lib/readOrCreateDefaultConfig'
import { getSnapshot } from './snapshot'
import { SOLV_TYPES } from '@/config/config'
import { spawnSync } from 'node:child_process'

export const getCommands = (solvConfig: ConfigParams) => {
const { locale, config } = solvConfig
Expand Down Expand Up @@ -64,6 +65,14 @@ export const getCommands = (solvConfig: ConfigParams) => {
monitorSolana()
})

get
.command('contact')
.description('Show Validator Contact Information')
.action(() => {
const cmd = `solana-validator --ledger /mnt/ledger/ contact-info`
spawnSync(cmd, { shell: true, stdio: 'inherit' })
})

get
.command('config')
.description(locale.cmds.config)
Expand Down
33 changes: 0 additions & 33 deletions packages/solv/src/cli/restart/createSnapshot.ts

This file was deleted.

12 changes: 0 additions & 12 deletions packages/solv/src/cli/restart/deleteSnapshot.ts

This file was deleted.

28 changes: 6 additions & 22 deletions packages/solv/src/cli/restart/index.ts
Original file line number Diff line number Diff line change
@@ -1,32 +1,16 @@
import { program } from '@/index'
import { ConfigParams } from '@/lib/readOrCreateDefaultConfig'
import { restartFetch } from './restartFetch'
import { restartSolv } from './restartSolv'

type RestartOptions = {
snapshot: boolean
}
import { spawnSync } from 'node:child_process'
import { MT_PATHS } from '@/config/config'

export const restartCommand = (solvConfig: ConfigParams) => {
const { cmds } = solvConfig.locale
program
.command('restart')
.description(cmds.restart)
.option('--snapshot', 'Restart Solana Validator with fetch snapshot', false)
.action(async (options: RestartOptions) => {
try {
if (options.snapshot) {
await restartFetch(solvConfig)
} else {
// TODO: Uncomment this line and update the createSnapshot function when The Solana team releases the new instructions
// Comment out for the usual restart
// createSnapshot(solvConfig)
await restartSolv(solvConfig)
}
} catch (error) {
console.log(
`If you failed to create a snapshot, please try - $ solv restart --snapshot`,
)
}
.action(async () => {
const config = solvConfig.config
const cmd = `solana-validator --ledger ${MT_PATHS.LEDGER} exit --max-delinquent-stake ${config.MAINNET_DELINQUENT_STAKE}`
spawnSync(cmd, { shell: true, stdio: 'inherit' })
})
}
26 changes: 0 additions & 26 deletions packages/solv/src/cli/restart/restartFetch.ts

This file was deleted.

4 changes: 2 additions & 2 deletions packages/solv/src/cli/scp/executeSCP.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ export function executeSCP(
isDownload: boolean,
) {
const cmd = isDownload
? `scp solv@${ip}:${key} ${filePath}`
: `scp ${key} solv@${ip}:${filePath}`
? `scp -o StrictHostKeyChecking=no solv@${ip}:${key} ${filePath}`
: `scp -o StrictHostKeyChecking=no ${key} solv@${ip}:${filePath}`
const result = spawnSync(cmd, { shell: true, stdio: 'inherit' })

return result.status === 0
Expand Down
2 changes: 1 addition & 1 deletion packages/solv/src/cli/scp/upload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export const upload = async () => {
if (!existsSync(filePath)) {
continue
}
const cmd = `scp ${filePath} solv@${answer.ip}:${key}`
const cmd = `scp -o StrictHostKeyChecking=no ${filePath} solv@${answer.ip}:${key}`
spawnSync(cmd, { shell: true, stdio: 'inherit' })
console.log(`Successfully Uploaded - ${fileName} 🎉`)
}
Expand Down
1 change: 1 addition & 0 deletions packages/solv/src/cli/update/updateSolv.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { spawnSync } from 'child_process'

export const updateSolv = () => {
spawnSync('pnpm add -g pnpm', { shell: true, stdio: 'inherit' })
const cmd = `pnpm add -g @epics-dao/solv`
spawnSync(cmd, { shell: true, stdio: 'inherit' })
}

0 comments on commit 891c78d

Please sign in to comment.