@@ -45,8 +45,9 @@ mappingRouter.post('/', async (req, res) => {
4545 const prodConfigApp = [ ...prodConfigure . apps ] [ 0 ]
4646 prodConfigApp . name = fullDomain
4747 prodConfigApp . env_production . PORT = parseInt ( req . body . port || portCounter , 10 )
48- prodConfigApp . script = 'npm'
49- prodConfigApp . args = 'run start:myproxy'
48+ prodConfigApp . script = `npm run start:myproxy << /home/myproxy/.pm2/logs/${ fullDomain } -out.log`
49+ prodConfigApp . error_file = `/home/myproxy/.pm2/logs/${ fullDomain } -err.log`
50+ prodConfigApp . merge_logs = true
5051 const prodConfig = {
5152 apps : prodConfigApp
5253 }
@@ -96,38 +97,34 @@ mappingRouter.post('/', async (req, res) => {
9697
9798mappingRouter . get ( '/' , async ( req , res ) => {
9899 const domains = getMappings ( )
99- if ( isProduction ( ) ) {
100- const data = await exec ( 'su - myproxy -c "pm2 jlist"' )
100+ if ( ! isProduction ( ) )
101+ return res . json ( domains . map ( el => ( { ...el , status : 'not started' } ) ) )
102+ const data = await exec ( 'su - myproxy -c "pm2 jlist"' )
101103
102- const outArr = data . stdout . split ( '\n' )
104+ const outArr = data . stdout . split ( '\n' )
103105
104- const statusData = JSON . parse ( outArr [ outArr . length - 1 ] ) . reduce (
105- ( statusObj , el ) => ( {
106- ...statusObj ,
107- [ el . name ] : el . pm2_env . status
108- } ) ,
109- { }
110- )
111- const fullDomainStatusMapping = domains . map ( el => {
112- if ( statusData [ el . fullDomain ] ) {
113- return { ...el , status : statusData [ el . fullDomain ] }
114- } else {
115- return { ...el , status : 'not started' }
116- }
117- } )
106+ const statusData = JSON . parse ( outArr [ outArr . length - 1 ] ) . reduce (
107+ ( statusObj , el ) => ( {
108+ ...statusObj ,
109+ [ el . name ] : el . pm2_env . status
110+ } ) ,
111+ { }
112+ )
113+ const fullDomainStatusMapping = domains . map ( el => {
114+ if ( statusData [ el . fullDomain ] ) {
115+ return { ...el , status : statusData [ el . fullDomain ] }
116+ } else {
117+ return { ...el , status : 'not started' }
118+ }
119+ } )
118120
119- res . json ( fullDomainStatusMapping )
120- } else {
121- res . json ( domains . map ( el => ( { ...el , status : 'not started' } ) ) )
122- }
121+ res . json ( fullDomainStatusMapping )
123122} )
124123
125124mappingRouter . delete ( '/:id' , async ( req , res ) => {
126125 const deletedDomain = getMappingById ( req . params . id )
127126 deleteDomain ( deletedDomain . fullDomain )
128- if ( ! isProduction ( ) ) {
129- return res . json ( deletedDomain )
130- }
127+ if ( ! isProduction ( ) ) return res . json ( deletedDomain )
131128 const gitUserId = await getGitUserId ( )
132129 exec (
133130 `
0 commit comments