Skip to content

Commit

Permalink
Allow the user to override the deploy name (allowing multiple copies …
Browse files Browse the repository at this point in the history
…of the

same release to run simultaneously as different deploys)
  • Loading branch information
timbod7 committed Dec 8, 2019
1 parent a4f6c23 commit 86de102
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 18 deletions.
12 changes: 7 additions & 5 deletions devdocs/help.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,15 @@ The following subcommands are used to manage reverse proxy deployments:
Show the proxy system status: specifically the endpoints and live
deploys.

## c2 start <release>
Create and start a deployment (if it's not already running)
## c2 start <release> [<asdeploy>]
Create and start a deployment (if it's not already running). The
name of the deploy is optional - if not provided it defaults to the
release name.

## c2 stop <release>
## c2 stop <deploy>
Stop and remove a deployment

## c2 connect <endpoint> <release>
## c2 connect <endpoint> <deploy>
Connect an endpoint to a running deployment

## c2 disconnect <endpoint>
Expand Down Expand Up @@ -104,4 +106,4 @@ Show the history of releases deployed via the start command.
## c2 show-default-nginx-config
Outputs the default template for the nginx config.

- [Userguide home](https://helix-collective.github.io/camus2/index.html)
- [Userguide home](https://helix-collective.github.io/camus2/index.html)
6 changes: 3 additions & 3 deletions src/Commands.hs
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,12 @@ import Util.Aws(mkAwsEnv)
import Commands.ProxyMode.LocalState(nginxConfTemplate)

-- Make the specified release the live release, replacing any existing release.
createAndStart :: T.Text -> IOR ()
createAndStart release = do
createAndStart :: T.Text -> T.Text -> IOR ()
createAndStart release asDeploy = do
tcfg <- getToolConfig
case tc_deployMode tcfg of
DeployMode_noproxy -> startNoProxy release
_ -> P.createAndStart release
_ -> P.createAndStart release asDeploy

startNoProxy :: T.Text -> IOR ()
startNoProxy release = do
Expand Down
13 changes: 8 additions & 5 deletions src/Commands/ProxyMode.hs
Original file line number Diff line number Diff line change
Expand Up @@ -86,21 +86,24 @@ showStatus showSlaves = do
T.putStrLn ""
T.putStrLn "Deploys:"
for_ (SM.elems (s_deploys state)) $ \d -> do
T.putStrLn (" " <> d_label d <> ": (localhost:" <> showText (d_port d) <> ")")
let labeltext = if d_label d == d_release d
then d_label d
else d_label d <> " (" <> d_release d <> ")"
T.putStrLn (" " <> labeltext <> ": (localhost:" <> showText (d_port d) <> ")")

-- | Create and start a deployment (if it's not already running)
createAndStart :: T.Text -> IOR ()
createAndStart release = do
createAndStart :: T.Text -> T.Text -> IOR ()
createAndStart release asDeploy = do
checkReleaseExists release
scopeInfo ("Create and start deploy " <> release) $ do
scopeInfo ("Create and start release " <> release <> " as deploy " <> asDeploy) $ do
pm <- getProxyModeConfig
tcfg <- getToolConfig
state <- getState
port <- liftIO $ allocatePort pm state
dcfgmodes <- return SM.empty
updateState (nextState (createDeploy port dcfgmodes))
where
createDeploy port dcfgmodes = (CreateDeploy (Deploy release release port dcfgmodes))
createDeploy port dcfgmodes = (CreateDeploy (Deploy asDeploy release port dcfgmodes))

-- | Stop and remove a deployment
stopAndRemove :: T.Text -> IOR ()
Expand Down
2 changes: 1 addition & 1 deletion src/Commands/ProxyMode/LocalState.hs
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ executeAction (CreateDeploy d) = do
tcfg <- getToolConfig
pm <- getProxyModeConfig
fetchConfigContext Nothing
let deployDir = T.unpack (tc_deploysDir tcfg) </> (takeBaseName (T.unpack (d_release d)))
let deployDir = T.unpack (tc_deploysDir tcfg) </> (takeBaseName (T.unpack (d_label d)))
liftIO $ createDirectoryIfMissing True deployDir
unpackRelease (contextWithLocalPorts pm (d_port d)) (d_release d) deployDir

Expand Down
9 changes: 5 additions & 4 deletions src/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ main = do

["status"] -> runWithConfig (P.showStatus False)
["status", "--show-slaves"] -> runWithConfig (P.showStatus True)
["start", release] -> runWithConfigAndLog (C.createAndStart (T.pack release))
["start", release] -> runWithConfigAndLog (C.createAndStart (T.pack release) (T.pack release))
["start", release, asDeploy] -> runWithConfigAndLog (C.createAndStart (T.pack release) (T.pack asDeploy))
["stop", deploy] -> runWithConfigAndLog (C.stopDeploy (T.pack deploy))
["connect", endpoint, deploy] -> runWithConfigAndLog (P.connect (T.pack endpoint) (T.pack deploy))
["disconnect", endpoint] -> runWithConfigAndLog (P.disconnect (T.pack endpoint))
Expand Down Expand Up @@ -162,10 +163,10 @@ usageText = "\
\\n\
\Deployment with a proxy:\n\
\ c2 status [--show-slaves]\n\
\ c2 start <release>\n\
\ c2 stop <release>\n\
\ c2 start <release> [<asdeploy>]\n\
\ c2 stop <deploy>\n\
\ c2 restart-frontend-proxy\n\
\ c2 connect <endpoint> <release>\n\
\ c2 connect <endpoint> <deploy>\n\
\ c2 disconnect <endpoint>\n\
\\n\
\Deployment without a proxy:\n\
Expand Down

0 comments on commit 86de102

Please sign in to comment.